Shop OBEX P1 Docs P2 Docs Learn Events
Did I pick the wrong controller? Or will carefull programming work. — Parallax Forums

Did I pick the wrong controller? Or will carefull programming work.

rob jacksonrob jackson Posts: 23
edited 2007-10-11 18:38 in BASIC Stamp
I'm building a control system for an Inertia (flywheel) Dynometer.· I was planning that I could just do some basic thing for safety as well.· Here is what I want to do.

1) Use a pot to control a 1/4 scale RC servo with PWM for throttle control.
2) Calculate the flywheel RPM and display it on the 4x16 LCD.
3) Monitor a coupler push buttons.·Emergency stop, Solenoids etc....

My thoughts since there are no hardware interupts to write very quick "sub routines" so that I can get back to the "main program" quick enough to keep an eye on the inputs and keep control of the servo.· Have to get back to the servo every 20ms is my understanding.

Also to use a tach I have to briefly read input counts on an input pin fast enough with a timer/counter several times.

I think the LCD code will be short and sweet.

Here are my thoughts about how to attempt this crudely?· Anyone ever write intense programs with the BS2 like this?

And am I heading in the right direction with program code like this?


'main program

DO
goto pbcheck
goto servocontrol
goto tachcheck
goto servocontrol
goto lcdprint
goto servocontrol
LOOP


'subprograms

servocontrol:
etc...
return

tachcheck:
etc...
return

lcdprint:
etc...
return

pbcheck:
etc...
return

END















▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank You,


Rob Jackson
oleancomputers.com
640 x 480 - 55K
640 x 480 - 59K

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2007-10-11 12:39
    Well, you really want to use "GOSUB" in this case, not "GOTO".

    The BS2 'plain' cycles at about 2000 Instructions/Second, or about 500 uSec/Instruction. So 20 mSec is about 40 instructions -- which is do-able. Also, the 'refresh' time of the servo gives you some freedom -- 20 mSec to 50 mSec will all work.

    Worst case, you can do a proof-of-concept using the BS2, to find out if it DOES have enough horsepower. From your description, it looks like it COULD work with careful programming. Down the road, you might have to 'upgrade' your processor to a 48sx, which DEFINITELY would have enough horsepower.
  • rob jacksonrob jackson Posts: 23
    edited 2007-10-11 14:58
    Thanks Allen for the reply.

    Sorry about the language mistake. I program G-code jumps and they use the gotof, gotob type commands. I'm glad I can pull this off possible. I bought two BS2s and the board of education with the sensors package.

    Sounds like I'll have to do some loop tuning to keep the servo smooth.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You,


    Rob Jackson
    oleancomputers.com
  • ZootZoot Posts: 2,227
    edited 2007-10-11 16:52
    Running the LCD, servo, button monitors, will be doable on a Stamp as allanlane5 suggests. But what's the estimated RPM range of the flywheel? How were you planning to sense the flywheel RPMs?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • rob jacksonrob jackson Posts: 23
    edited 2007-10-11 17:08
    Zoot,

    Glad you thought enough about it to ask. The flywheel RPM normally will no greater the 1800RPM's. 1500RPM normally.

    My thoughts were to monitor an input for short ranges of time and use a varible to count the number of pulses. From that try and calculate the RPM. I can only view the inputs for a short period as I have to get back to the servo quickly.

    I surely don't have all the answers. The RPM issue may be the toughest challange yet.

    I'm open to suggestions!

    Plan was to use a magnet and an inductor for "noise" pulses.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You,


    Rob Jackson
    oleancomputers.com
  • ZootZoot Posts: 2,227
    edited 2007-10-11 17:26
    OK, bear with me because I'm thinking out loud -- I think this depends on how many pulses (ticks) you get per revolution of the flywheel. If only one tick per revolution, it'll be to slow because... Say at 2000rpm you'd get 2000/60 = 33.3333 pulses per second, divided by 1000 is ~.03 pulses per ms, so figure roughly about one pulse from the hall effect sensor on the flywheel every 30ms or so. Does that sound about right? So the potential trap I see is that you don't have a fast enough flywheel to be able to COUNT pulses, for say 10ms, then spend another 10ms with housekeeping (e.g. LCD, button monitoring) then send the servo pulse to the throttle within the 20-25ms time frame.

    So you want to have enough pulses per revolution that you can do a meaningful COUNT of, say, 5-10ms every 20 ms or so. See the COUNT command in Stamp Manual for info about each stamps frequency and duration specs on pulse counts.

    All the faster RPM monitors I've seen around the forums have been SX or Prop based (they are much faster and can handle higher frequency rates "in the background"), but at speeds this (relatively) slow I would think it would be doable if the LCD routines and such are kept short (a parallel LCD will be faster, btw, if you have the pins).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • rob jacksonrob jackson Posts: 23
    edited 2007-10-11 17:42
    Zoot,

    Your logic sounds reasonable. I have to stop and think about this one as well.

    Here is my next thought. Let me know if you think this could work...

    Let say I need more pulses to make this routine quick. Maybe a train of magnets close together would be the answer. Grouped together not all symetrically around the whole flywheel???

    It is going to be interesting to time all this. I need a scope I'm thinking.

    I'll be working on this tonight when I get home. I'll try and run all the math. Gotta do this and still make time for the servo. The whole madness behind this is to prevent the flywheel from overspeed issues. In the event someone gears the dyno wrong the BS2 can hit the brakes and throw up an alarm.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You,


    Rob Jackson
    oleancomputers.com
  • ZootZoot Posts: 2,227
    edited 2007-10-11 17:52
    Well, at one revolution per 30ms, I don't think you need to group magnets (then you'd have a balance problem anyway?). Say you put 24 magnets around the wheel, that cuts you down to near 1ms per pulse, so you'd get sample of 10 in 10ms (actually a little less). If you put 48 magnets on the wheel (or more) you'd get it even better -- more samples per 8-10ms will give you more accuracy ESP. if overspeed/safety is an issue.
    I would go to search.parallax.com and search the site "forums.parallax.com" for some of the SX and Prop projects that monitor (much faster) RPMs -- it might give you some better ideas about sensor arrangements.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • rob jacksonrob jackson Posts: 23
    edited 2007-10-11 18:38
    Balance should not be an issue. The flywheel is 28" diameter! 1"thick steel. Weighs about 200lbs. A quick three magnet train should not effect it.

    I totally appreciate the help your giving.

    I'll give some sample code some thought and see what you think.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You,


    Rob Jackson
    oleancomputers.com
Sign In or Register to comment.