Serially "burnable" lookup table

Coyoteboy

Senior Member
G'day all,

Its 3AM here so my mind is working on overdrive but....

Im looking at making a single servo controller from an 08M that monitors a shaft speed and adjusts the servo position based on a lookup of the shaft speed...easy enough so far, just select a set of ranges and number them, determine which range the speed is in and lookup a value - bingo. BUT...

I want the values for servo control output to be programmable via serial cable - so I send a string like "8 11 15 22 28 21 30 60 100" to the 'axe via serial DL cable and try it...if it doesnt work as planned i send "8 11 15 22 28 32 39 50 130" and it adjusts the table. Finally I need these to be non-volatile so its read/write time - ive no experience of these yet.

Oooh what fun! So, what pitfalls should I try to avoid?
 

hippy

Technical Support
Staff member
Three things which may trip you up -

1) The internal Eeprom is zeroed or set to EEPROM statement values on a download so write down the last numbers sent / update your code.

2) You cannot easily have a SERIN in the middle of your looping code so you'll need a mechanism to be able to 'interrupt', enter new data then continue.

3) Define the complete table of correct size using EEPROM to avoid corrupting your executable code.

Given the one million writes you can do before nuking a PICAXE and that you will have to stop the loop anyway to read new data, it may be much easier to update the EEPROM statement table in the source code and download again. That's personally the way I'd do it.
 

Coyoteboy

Senior Member
OK, lets see if I understood... :)

1) I'm not sure what you're meaning is there - can you give a short example scenario? Do you mean I wont be able to retrieve my last input numbers?
2) I was considering a "program pin" sort of arrangement - maybe throwing the sytem into a "serin loop" until it is removed?
3) I was hoping to have the end user unable to read/edit the code - I wanted to just write a bit of software to run on a laptop that presents a table, much like tuning a car EFI system, in which the user can enter a table of maybe 8-10 values and then send them to the axe. This would allow the user to set up some positions by theory, then return after a test and maybe tweak the positions later if theory didnt match practice, as it never does. It would be good to be able to read the existing positions back off the axe next time the software/laptop is attached but that is of secondary/little importance.
 

Tom2000

Senior Member
Normally, your idea wouldn't work because once you issue a SERIN command, the program will hang until you receive serial input. Since you're writing your own laptop software, though, you have a loophole which makes your system viable.

In your laptop software, issue an RTS over the serial link to tell the 08M you want to send it some serial data. Upon receipt of the RTS, the 08M can move the servo to a safe position, then issue the SERIN instruction.

One 08M output might be used as either a CTS/DTR signal or serial data toward the laptop.

Within the 08M, you could use write instructions to place user data in EEPROM.

08M leg assignments might be 3 for the serial input line, 4 for the shaft sensor, 5 for the servo output, 6 for RTS in, and 7 for either CTS/DTR or serial data toward the laptop. (Nothing is set in stone for those pinouts. Those are just the ones I placed on my sketch to make sure you have enough gozintas and gozoutas on the 08M for this system.)

Good luck!

Tom
 

hippy

Technical Support
Staff member
If it's end user programmabilty needed then; "what Tom2000 said".

To minimise code you'll want the simplest 'report current values' and 'upate values' routines, but that's not a problem when controlled by your own software. The PC will be connected, when a "Connect" button is clicked, the PC can raise RTS or whatever, the PC can read the 8-10 binary byte values, they can be changed, then sent back with a click of a "Store" button. When a "Disconnect" button is clicked or the application closed, RTS can be lowered and the 08M will continue back in its main loop.
 

Coyoteboy

Senior Member
I'd like to use the RTS pin idea, but i wanted to minimise size somewhat and that would mean using more than the 3 pin headphone connection, which is possible but not ideal. I could use a servo-style inline 4 connection i suppose. I think I'd be happy to have a jumper that would be applied to lock the system into "programming mode" without servo position alteration - when programming the system would be either disconnected from the servo or the servo position irrelevant anyway- it could flounder around happily. I'll knock up some pseudocode and see how i get on. Will keep you informed, thanks for the help!
 

hippy

Technical Support
Staff member
You can use a two wire plus 0V D/L-style link by having your program check the level on the RX pin and SERIN after it is activated. You can invoke it by throwing characters at the PICAXE until it sees one or set the 'break' signal - Exactly how the PICAXE download mode itself works.

You should be able to use interrupts to detect when something is first sent to the PIACXE.
 

Wrenow

Senior Member
G'day all,

Its 3AM here so my mind is working on overdrive but....

Im looking at making a single servo controller from an 08M that monitors a shaft speed and adjusts the servo position based on a lookup of the shaft speed...easy enough so far, just select a set of ranges and number them, determine which range the speed is in and lookup a value - bingo. BUT...

I want the values for servo control output to be programmable via serial cable - so I send a string like "8 11 15 22 28 21 30 60 100" to the 'axe via serial DL cable and try it...if it doesnt work as planned i send "8 11 15 22 28 32 39 50 130" and it adjusts the table. Finally I need these to be non-volatile so its read/write time - ive no experience of these yet.

Oooh what fun! So, what pitfalls should I try to avoid?
I know this is not exactly what you asked, but....

If you can determine the shaft speed, why not just do the maths to output the servo position? You can, of course, adjust the formula as needed. Pretty easy to tweak there as well.

Seems a lookup table that covers the 150 possible servo positions gets pretty voluminous.

Cheers,

Wreno
 

Coyoteboy

Senior Member
I had considered this option but the output may not be proportional and may need to contain steps - ideally i'd linearly interpolate between positions, but even so this isnt going to be a 150 cell table, only 10 or so. Linterping between would make the system ideal but also possibly be beyond the total programming size of the IC.
 

Wrenow

Senior Member
The maths do not need to be directly proportional in results, and can easily contain steps or skews based upon conditions, I would think. And, it would probably take up less programming space, methinks. Could be wrong, though.

What I would do is get the RPM counting portion working, and see what the physical results are actually being received. Then see how you need to adjust it to fit the servo.

Or, perhaps you are not really doing a servo so much as feeding the servo signal to an ESC to adjust shaft speed? Or, is it a trim tab? Crystal ball is a bit hazy. ;-)

Cheers,

Wreno
 

Coyoteboy

Senior Member
:) The shaft speed is just controlling the position of something else, the servo feedback isnt affecting the engine control. I don't want to give too much away before its completed lol. As you say I'll get the shaft reading right and work from there! I'm not dismissing your idea at all, certainly the theoretical link between shaft speed and servo position will be linear, but i think it may form something of a cubic shape when in real world, and may change from one application to the next - hence needing total customisability. I'll see if either can be done and report back - just had a bit of a family emergency so give me a few days!
 
Top