-1

I'm working with embedded systems. For the sake of explanation, I'm working with a dsPIC33EP and a simple serial EEPROM.

Suppose I'm building a controller that uses a linear control scheme (y=mx+b). If the controller needs may different setting It's easy, store the m and the b in EEPROM and retrieve it for the different settings.

Now suppose I want to have different equations for different settings. I would have to pre program all the equations and then have a method for selecting that equation and pulling the settings from the EEPROM. It's harder because you need to know the equations ahead of time but still doable.

Now suppose that you don't know the equations ahead of time. Maybe you have to do a piece wise approximation for example. How could you store something like that in memory? That all a controller has to do is feed it a sensor reading and it would give back a control variable. Kind of like passing a variable to a function and getting the answer passed back.

How could you store a function like that in memory if only the current state is important?

How could you store a function like that if past states are important (if the control equation is second, third or fourth order for example)?

vini_i
  • 325
  • 1
  • 7
  • 14
  • Are your equations of the form **y = a + bx, y=a + bx + cx², y = a + bx + cx²+ dx³** or are they more complex than that? If it is simple, what is the range of the powers of x? – cup Aug 27 '17 at 19:45
  • @cup Yes, the equations are in that form with cubed being the highest order. The exception is that they can also be piecewise defined, sometimes mixed and matched. For example, the first range is y = a + bx and the second range is y = a + bx + cx^2. The other outside case is interpolated values. For example low range is y = 2 + 5x + 7x^2 and the high range is y = 1 + 7x + 19x^2. Then in between its some linear interpolation of the coefficients. For example, directly in the middle, it would look like y = 1.5 + 6x + 13x^2. – vini_i Aug 28 '17 at 13:57
  • So for each setting you have a range of coefficients and you want to narrow down to a specific set of coefficients based on past states in some settings and on the current state in other settings. Once it is switched off, unless the data is stored in NVRAM, you won't have any previous states to refer to. – cup Aug 29 '17 at 04:31
  • @cup Not quite, the settings are hand tuned to function as needed for the particular application. After the settings are finalized as working, they are rarely if ever touched again. This is all done in a development system. The caveat is that those settings then need to be rolled out later to a lot of non-development systems to use. The trick is to make the controller generic enough that when the control equation is not normal the controller can still use the setting. – vini_i Aug 29 '17 at 12:16
  • How do you store the equation at the moment - is it just the coefficients? What are these settings and how are they stored in a non dev env? Is it a set of values to help configure the coefficients, say by least squares? – cup Aug 29 '17 at 19:15
  • @cup The controller has several standard equations. The EEPROM then contains the coefficients and equation type. When the controller switches settings the coefficients and equation type is pulled from memory. To do updates there is a USB link that can write new values to the EEPROM. This covers about 90 to 95% of cases. When we hit one of those special cases the unit has to be shipped back and the firmware of the controller updated to include the new equation. Unfortunately, this now makes that controller custom and there is a fair amount of down time. – vini_i Aug 30 '17 at 12:05
  • Would it be possible to distribute the USB link program and modify it in such a way that it 1) checks that it can contact you online 2) sends the new parameters that the customer is using 3) does the USB link to update the data. Updating online is like a licencing option - if you cannot be contacted, then the program does not run and they have to send the system back. – cup Sep 04 '17 at 15:17
  • @cup Updating the parameters is not really a problem for the standard stuff. What we want to avoid is having units sent back and making them custom. The process of writing the EEPROM is virtually foolproof and can't brick the unit. We've avoided updating the firmware in the field to avoid bricked units. – vini_i Sep 04 '17 at 19:57

1 Answers1

1

The dsPICs have limited RAM, but quite a bit of FLASH, enough for a small, but effective text parser. Have you thought of using some form of text based script? These can be translated to a more efficient data format at run-time.

Michaël Roy
  • 6,338
  • 1
  • 15
  • 19