Shop OBEX P1 Docs P2 Docs Learn Events
Is Parallax right for me? — Parallax Forums

Is Parallax right for me?

blakrapterblakrapter Posts: 38
edited 2005-09-24 03:04 in BASIC Stamp
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!

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-22 14:42
    Unless my math is wrong, a table that size would consume 240,250 bytes of memory.· This is more than you have to start, even on our BS2pe.··You would require an·EEPROM large enough to hold all of that data.

    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
  • blakrapterblakrapter Posts: 38
    edited 2005-09-22 14:50
    Chris, thanks for the reply. I considered runing calculations, which is possible, but I assumed it would be faster to lookup a value. Is it possible to add memory somehow?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-22 15:04
    You could add external SPI EEPROMs, then you'd need your code to base it's access to the table on x/y offsets (index).· 3D tables are fun to implement, but you will need a program just to store all the data first.· I would make it so that you can easily adjust individual values.

    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
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-22 17:04
    By my calcuations 155x155 (bytes) is 24,025 -- still bigger than what a BASIC Stamp can accomodate in EEPROM. If a table is indeed required, you could connect a 24LC256 EEPROM to a BS2px and have 32K of tables. On the same I2C buss you could connect an ADC to read your joystick(s).

    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
  • metron9metron9 Posts: 1,100
    edited 2005-09-22 17:07
    Somebody said...
    I need to send a bunch of analog voltages (0-5VDC)

    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.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-22 17:25
    Jon,

    ·· 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 WilliamsJon Williams Posts: 6,491
    edited 2005-09-22 18:48
    Sorry, missed that part.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-09-22 19:58
    I'd recommend an ATMEL dataflash like the AT45DB041 for the large data table. (1/2 megabyte in an 8 pin package)

    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
  • blakrapterblakrapter Posts: 38
    edited 2005-09-22 20:48
    Hi everyone. Thank you very much for the help. If possible, could you explain what the components you mentioned do? I am new to this stuff and am not quite sure what a I2C DAC or 24LC256 is. I know in general what an ADC and a DAC does, I am not familiar with those specific components.

    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 WilliamsJon Williams Posts: 6,491
    edited 2005-09-22 21:02
    Can you explain your application in more generic terms? I'm still trying to figure out how you're going to use all this table data.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • metron9metron9 Posts: 1,100
    edited 2005-09-22 21:13
    I am thinking you dont need all that data but I don't know a few things so I am guessing. Just throwing in some extra questions to think about in the design phase.

    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.
  • blakrapterblakrapter Posts: 38
    edited 2005-09-22 21:15
    Sure. Here is the setup: I will have 2 high voltage/current motor controllers, MC1-HV to be exact. If you are not familiar with them, they are generic motor/speed controllers that control the speed of the motor by automatically adjusting the voltage and/or current to the motor. The purpose of the STAMP is to control both simultaniously with a signle joystick for "skid steer".· The speed input signal needs to be PWM (set up that way from the factory); no problem. Now, the MC1-HVs also have built in current, speed, accelleration, and decelleration adjustments. These are normally set 1 time by the installer/builder by adjusting pots on the board and then left alone. I have been told by the manufacturer that I can get rid of the pots and replace them with a 0-5V signal. This will allow me to adjust all of the parameters on-the-fly.

    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
  • blakrapterblakrapter Posts: 38
    edited 2005-09-22 21:26
    Uh-o. I made a big mistake... Told you I was new to this... Its actually 255 x 255, not 155x155.... I got my numbers mixed up. That 255 comes from converting an analog signal to an 8 bit digital signal... Sorry. The concept stays the same though...

    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
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-22 23:07
    Okay, I've never been accused of been the smartest guy in the room, but neither have I been accused of being the least practical. What I mean is this: It may be easier to work the calculations for your 5-volt outputs (I'd use digital pots to replace your mechanical units) into the Stamp than it would be to calculate and program several thousand table values.

    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
  • blakrapterblakrapter Posts: 38
    edited 2005-09-23 12:50
    Jon, and everyone else too, thanks for the input. After I realized I goofed on the resolution and calculated the size of a 255x255x10 table (which turns out to be something like 60 or 80 megs), I realized equations will have to work, even if I need multiple processors to do it. I am currently working on the equations and unfortunatly, they will not be linear. The speed equation is a 2nd order polynomial and I suspect the accelleration and deccelleration curves will be exponential (I will start with linear, but I doubt they will work well that way). I may leave the torque and max speed alone and not adjust them on the fly. Almost all of the equations will be broken up as well; meaning different equations will be used depending on which quadrant the joystick is in. Most of my programming experience is with MatLab, so that would be done with "if" statements. I am sure basic is somewhat similar. Again, I do not know about the speed of the calculations though. I sounds like the um-FPU may be the answer to the speed problems with complex equations.

    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 WilliamsJon Williams Posts: 6,491
    edited 2005-09-23 13:14
    I think you're going to have to do it empirically, especially if you use the FPU which will introduce its own delays. That said, I believe you should be able to accommodate the ten updates per second you were originally looking for. That's just my guts (after 12 years of Stamp programming) talking, though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • blakrapterblakrapter Posts: 38
    edited 2005-09-23 13:19
    Thanks for the reply. I was editing while you were replying I think. Here's what I added:

    "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 WilliamsJon Williams Posts: 6,491
    edited 2005-09-23 13:58
    I agree: it's best to build a prototype and learn from it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • metron9metron9 Posts: 1,100
    edited 2005-09-23 16:31
    Somebody said...
    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.

    Without a ramp code might look like this

    loop:
    Joystick position change
    Set speed
    loop

    Ramp code could look like this:
    loop:
    Joystick position change
    update variable to desired speed (instead of changing the speed here)
    (Logic to ramp)
    if current speed <> desired speed
     if current speed < desired speed
       if x ms has elapsed
        increase speed by ramp amount
       endif
     else
      if x ms has elapsed
       decrease speed by ramp amount
      endif
     endif
    endif
    goto loop
      
    So you just set up variables to hold the desired speed and use a time clock to space the increase or decrease till the desired speed is reached.
    I used this type of logic alot when programming games.
    
    
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-09-23 16:53
    If the math relations are second order polynomials, that might still be resolved with math native to the Stamp, or, if the curves are not too convoluted, with a relatively small table and linear interpolation.

    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
  • blakrapterblakrapter Posts: 38
    edited 2005-09-23 20:18
    Thanks for all of the help so far.· I decided to quickly sketch·a simple schematic of the system (attached) and what I need to stamp(s)/processors to do.· The ultimate goal is to build a skid-steer machine that is easy to drive.· I need two motors and motor controllers to achieve the skid steer and I need the stamp to give me (or help give) an easily maneuverable machine.· To make it easy to drive, the speed, accelleration, and decelleration need to be adjusted constantly in relation to the joystick position.· The controllers have these adjustments built in, but they the accel and decel are intended to be set at installation and not changed.· The controllers also allow the max speed and torque to be adjusted, but I don't think I need that.

    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.
    640 x 551 - 42K
  • metron9metron9 Posts: 1,100
    edited 2005-09-24 03:04
    Somebody said...
    a skid-steer machine that is easy to drive.

    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.
Sign In or Register to comment.