Is Parallax right for me?
blakrapter
Posts: 38
Hi everyone, I have a question for you stamp experts.· I have an application where I need to send a bunch of analog voltages (0-5VDC) out to "adjust" different parameters on large motor controllers.· The controllers allow me to adjust (or will once modified) acceleration, speed of course, decelleration, current, etc "on the fly" by· varying the voltage·at·individual pins for the·assigned performance perameters.· I will be running 2 motor controllers for a total of ~10 parameters I need to control.
I want the microprocessor·to read·an X and Y joystick input and lookup the values of each parameter voltage in a table.· So, basically what I will have is a 155x155 (X x Y)·table that has at least 10 values in each cell that will set the value of the output pins.· I am worried about two things:
1.· Will it be able to do this fast enough?· I need·it to "update" all of the outputs at least 10 times/sec, but preferably faster.
2.· Is a table of this size possible?· Both with memory requirements and multiple values/cell?
Also, if there are any other issues you see, please let me know.· It would also be nice to have the ability to expand for more controllers/parameters, but it is not a necessity b/c I can run multiple processors if needed.
Thanks!
I want the microprocessor·to read·an X and Y joystick input and lookup the values of each parameter voltage in a table.· So, basically what I will have is a 155x155 (X x Y)·table that has at least 10 values in each cell that will set the value of the output pins.· I am worried about two things:
1.· Will it be able to do this fast enough?· I need·it to "update" all of the outputs at least 10 times/sec, but preferably faster.
2.· Is a table of this size possible?· Both with memory requirements and multiple values/cell?
Also, if there are any other issues you see, please let me know.· It would also be nice to have the ability to expand for more controllers/parameters, but it is not a necessity b/c I can run multiple processors if needed.
Thanks!
Comments
It would seem like there would be a way to linearize your calculations somehow so that you only need some range values, and everything else in between could be calculated.· Of course, without the details of the motor controller it would be hard to advise how.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Jon and/or Tracy might have some better suggestions.· All I can think is a range equation, since the table size here seems really large.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
The BS2px is the fastest in our line and will give you the best performance -- of the BASIC Stamps. Of course, you could also use the same strategy with an SX chip and get much faster speed running compiled SX/B (you'd still connect the 24LC256 and I2C [noparse][[/noparse]or other] ADC).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Could you give an example of the 10 voltages in cells 1,1.... 155,1.... 1,155... and in cell 155,155
I would think as Chris said with that information and perhaps two more 155 byte arrays you could do a pretty fast calculation
How many voltages in the 0 to 5 volt range? if that's small you could set up more tables in smaller bitmaps that could save alot of memory.
·· I came up with a larger number because he specified 155x155 with 10 parameters for each coordinate, this would give a 3D table of 240,250 bytes unless the 10 parameters could be brought down to one.· I still think it's overkill, but we'll see if he can pull it off.· Good luck to the OP!·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
And I'd guess you could read the X-Y from a dual channel ADC, calculate the offset into a lookup table, read in 10 bytes, and send them to a multichannel 8 bit DAC all within 20 milliseonds. That would allow 50 updates per second. It would be faster on one of the faster Stamps. Choose those chips that allow the conversions to be done in one operation, without a lot of instruction back and forth.
If you want to use a nice I2C DAC or ADC, then by all means choose one of the more recent Stamps that supports native I2C.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
For the example of cell values; basically I need 10 values for each cell. For instance (just making numbers up here), cell 122,159 would have 10 values in it, say 123, 023, 139, 083, 149, 155, 021, 074, 142, 001. Each value would be assigned to a pin, say pins 4-13 and converted to a 0-5V signal through a DACs. So, after the DACs I would have 10 wires with a different voltage in each wire.
Also, if it would be better to use an equation or set of equations to calculate the parameters each time that is OK, I just assumed it would be slower that way. Is that the case?
Thanks again for your help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I see your highest number is 122 so you need at least 7 bits so
using one byte for each cell (times 10 values of course) you can hold a number from 0 to 255 that will represent a voltage from 0 to 5 volts in .019 volt steps
1. Is there a difference in the motor controllers in that small of a voltage change
2. How much resolution does a DAC have? so would there be a change in the DAC output in .019 volt steps? (I am just learning about DACs as well)
I guess an 8 bit DAC would give you 255 values but someone else will have to jump in here as I dont know.
Another thing is the setting time on the DAC, and I don't know either but I think that means how long it takes to reach the voltage requested.
3. is the data linear, i.e. increments by a set amount for each step across or down the table of 155 x 155 ? or is there a log table you could set up 155 x 2 that could hold increment and decrement values as the joystick moves around the table? If so you dont need all that data.
For instance, with my setup, I want the accelleration to decrease while turning, so, the "accelleration" and "decelleration" voltage needs to be lowered when turning, i.e. the joystick is shifted left or right. I will use a table to "map" all of the possible the joystick positions and then assign a value for each parameter output for each position (still working on how to do this in a spreadsheet or something). There are the 5 parameters, which I mentioned above, and 2 motor controllers, so thats a total of 10 outputs I need. 8 of these will be analog which will essentially replace thepots and 2 PWM. Hopefully that will clear it up a little.
Post Edited (blakrapter) : 9/22/2005 9:28:23 PM GMT
Also, metron9, that 122 was arbitrary, it could be as high as 255 (which would equal 5V). I might be able to get away with a lower resolution, but I wont know until I build it. I would like to plan for the highest resolution possible... That way, at lower speeds, it won't be "jumpy."
I am also not sure if·the relationship between steps·will end up being linear. I plan to set it up that way to start with and "adjust" if necessary.
As for the smallest voltage step the controller will recognize,I will have to check, however, I would guess it is pretty small b/c they claim to offer precise control.· Also, it may or maynot support -5V to 5V, so that voltage·step would double if it does... My guess is the analog adjustments do not go -5 to 5, but 0-5. I will have to check on that as well. Now, I could probably get away with a lower "resolution" for the analog parameter outputs (the ones that replace the pots), but the max value in digital terms would still range from 0-255 because I still need the full voltage range, so I doubt it will help with our table size issue.
Post Edited (blakrapter) : 9/22/2005 9:25:38 PM GMT
If the relationship is complex (i.e., non-linear), you might consider adding a floating-point math coprocessor instead of table EEPROM. The um-FPU that we sell allows you to build equations into it. You could send it you inputs, tell it to run a complex set of equations, then get the values back for your output pots.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
If I remeber correctly from when I programmed a stamp 5 years ago, one can easily determine the time it would take to run a code by counting the lines. Is this correct? I am VERY rusty on this, but it seems like we always had only 1 command or calculation per line and it was known how long it took the processor to run 1 line of code. This may or maynot have been the case then and may or maynot be the case now, but regardless, how can I get an estimate of how long it will take to run the necessary calculations?
Of course, there is another solution too that I threw out a while back due to complexity.· With everything considered though, it may not be too complex.· If I decide to not adjust the torque on the fly, all that really matters is the speed.· In the end, the speed at the wheels is what it all boils down to.· I could manually set the accel and deccel on the motor controller board to the max I consider to be safe.· Then, ramp up or down the speed PWM input as needed to control accelleration.· For instance, if I have accelleration set as high as it will go at the motor controllers, but I slowly push the joystick forward, the motors will accellerate at the rate of the joystick.· The only time the motor controller accelleration limit comes into play is if I accellerate the joystick faster than I want the wheels to accellerate (i.e. I slam the joystick forward).· But, if I set the motor controller accelleration to MAX and then I use the stamp to control the rate at which the PWM speed signal ramps up, I could achieve the same result...· For instance, lets say I determine that an acceptible max acceleration would be 1 second from 0 to 100% speed.· That means if I instantly push the joystick full foward, then the PWM needs to ramp up to 100% over a 1 second interval.· If I press the joystick half way, it needs to ramp up to 50% over .5 second (assuming a linear relationship, which it probably wont be).· However, I have NO CLUE how to do that.
Thanks again for all of your help, keep it coming!
Post Edited (blakrapter) : 9/23/2005 1:12:42 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
"Of course, there is another solution too that I threw out a while back due to complexity. With everything considered though, it may not be too complex. If I decide to not adjust the torque on the fly, all that really matters is the speed. In the end, the speed at the wheels is what it all boils down to. I could manually set the accel and deccel on the motor controller board to the max I consider to be safe. Then, ramp up or down the speed PWM input as needed to control accelleration. For instance, if I have accelleration set as high as it will go at the motor controllers, but I slowly push the joystick forward, the motors will accellerate at the rate of the joystick. The only time the motor controller accelleration limit comes into play is if I accellerate the joystick faster than I want the wheels to accellerate (i.e. I slam the joystick forward). But, if I set the motor controller accelleration to MAX and then I use the stamp to control the rate at which the PWM speed signal ramps up, I could achieve the same result... For instance, lets say I determine that an acceptible max acceleration would be 1 second from 0 to 100% speed. That means if I instantly push the joystick full foward, then the PWM needs to ramp up to 100% over a 1 second interval. If I press the joystick half way, it needs to ramp up to 50% over .5 second (assuming a linear relationship, which it probably wont be). However, I have NO CLUE how to do that."
What do you think about this option?
Thank you again for all of your help. I think my best bet is to just go ahead and build a prototype and see how it goes. I like to have all of my ducks in a row before I start something. I think most of them are now, my best bet is probably to go ahead and try it.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Without a ramp code might look like this
loop:
Joystick position change
Set speed
loop
Ramp code could look like this:
However, correct me if I am wrong, each polynomial might be a function of several different variables. That would complicate things. Say, acceleration might depend not only on the joystick position, but also on the current position relative to the desired position. Thus the newer ramping scheme. I too am a bit unclear on what kind of contraption you are working on! For example, is it something like a machine tool where these parameters will be set by manipulation of the joystick and then left alone for a long period of time, or, soemthing like a vehicle, where you will be using the joystick dynamically to drive it?
You asked about I2C. It is a protocol originated by Philips Corp, but now widely liscenced and poplular. It creates a bus using two signal lines (clock and data), and you can generally put several different devices on the bus, sharing the same two signal lines. Each device knows when it is allowed to "talk", because each device has its own address that is parsed out by the master controller. The BASIC Stamp can be the master controller, and the BS2p, BS2pe, and BS2px have native (meaning fast) support for the I2C bus. You can also do I2C on the earlier Stamps, but at a much much lower speed of operation. Examples of I2C chips are the 24LC256 EEPROM memory, the MAX521 DAC (digital to analog, 8 bits, 8 DAC channels in one chip), the MAX1236 ADC (4 input channels, 12 bits), the DS1307 RTC (real time clock + ram). You could have all of those chips connected to your BASIC Stamp and occupy only two I/O pins!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
The motor controllers I have chosen use a standard PWM signal for the speed input.· Now, with some modification, I can adjust the accelleration, decelleration, torque, and max speed with analog signals.· As mentioned, I think I am going to drop the torque and max speed because torque control isn't as important for easy handling and top speed can easily be adjusted by just not giving a speed input faster than I want.· So, what it all boils down to is I have 3 inputs for each motor controller: speed, accelleration, and decelleration, all of whose values are functions of the joystick position.· Unfortunatly, they are not linear functions...· For the ones I've played with it looks like they will end up being 2nd and 3rd order polynomials and exponential functions.
The way I have broken it down is·the parameters·are functions of the distance from the origin to the joystick position ("r")·and the angle that the distance vector makes with the Y axis, alpha·(noticed diagram in top left of attachment).· From there, the diagram breaks down what needs to be calculated.· I only drew one controller b/c I didn't have much room, but there will be two.
Also, one more note.· For the speed calculation I put it is a 4 step process.· The stamp must first determine which quadrant the joystick is in (this will assign the equations for each speed).· Then calculate the magnitude of the right and left motor speeds, then calculate the direction (sometimes they go the same direction, sometimes only one wheel turns, sometimes they turn opposite directions).· Hopefully this will help explain it more.
Problem is, any good skid-steer machine uses Hydraulics, and a diesel engine,
you can't put enough batteries in one to get that kind of power.
and one more thing they are easy to drive, sure the turbo new hollands take a little time getting use to after running a bobcat
but just drive it for 1/2 hour or so and you can pick up a dime off the floor given a sharp blade.