Did I pick the wrong controller? Or will carefull programming work.
rob jackson
Posts: 23
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
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
Comments
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.
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
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
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
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
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
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