PWM question
Archiver
Posts: 46,084
I'm very new to this basic-stamp stuff, but have been programing for
quite some time (mostly web stuff, php+mysql, but some
c,c++,c#,basic).
My question is:
Say I have 3 servos connected to my basic stamp. Each one needs to
recieve 50 pulses a second... how do I make sure they get this while
still making decisions on input?
It seems that in order to get 50 pulses/sec (or anything close to
that) on a single-task processor (go basic stamp!) I would have to
advoid long cycles..
Here is a example program (not in pbasic, I don't know the syntax
well enough).
'init some vars here
'send pmw pluses
MAIN: 'main loop
pulse(time1,pina) 'pulse for first servo
pulse(time2,pinb) 'pulse for second servo
pulse(time3,pinc) '..
for(i=0;i<1000;i++)
{
check for a input, need servo motors to stay in the same
place/continue at the same speed...
}
Would it be ok to make a sub routine to update the servo's and then
call this sub-routine inside every loop? Im confused -- maybe there
isn't even an answer to my question.
Thanks,
Greg
GOTO MAIN
quite some time (mostly web stuff, php+mysql, but some
c,c++,c#,basic).
My question is:
Say I have 3 servos connected to my basic stamp. Each one needs to
recieve 50 pulses a second... how do I make sure they get this while
still making decisions on input?
It seems that in order to get 50 pulses/sec (or anything close to
that) on a single-task processor (go basic stamp!) I would have to
advoid long cycles..
Here is a example program (not in pbasic, I don't know the syntax
well enough).
'init some vars here
'send pmw pluses
MAIN: 'main loop
pulse(time1,pina) 'pulse for first servo
pulse(time2,pinb) 'pulse for second servo
pulse(time3,pinc) '..
for(i=0;i<1000;i++)
{
check for a input, need servo motors to stay in the same
place/continue at the same speed...
}
Would it be ok to make a sub routine to update the servo's and then
call this sub-routine inside every loop? Im confused -- maybe there
isn't even an answer to my question.
Thanks,
Greg
GOTO MAIN
Comments
replace several IF-THEN statements. For robotics projects, I typically setup
my program like this:
Main:
GOSUB Update_Servos
BRANCH task, [noparse][[/noparse]Task_0, Task_1, Task_2, Task3]
task = 0 ' task value was invalid
PAUSE 20
GOTO Main
Task_0:
' check sensors
' update task value
PAUSE x ' set x so task code takes about 20 milliseconds
GOTO Main
With this design your servos get updated every 20 milliseconds or so as they
desire and each task can intelligently control program flow by setting the
next task based on current conditions.
HTH.
-- Jon Williams
-- Parallax
In a message dated 9/1/02 10:43:12 AM Central Daylight Time,
gregt@t... writes:
> I'm very new to this basic-stamp stuff, but have been programing for
> quite some time (mostly web stuff, php+mysql, but some
> c,c++,c#,basic).
>
> My question is:
>
> Say I have 3 servos connected to my basic stamp. Each one needs to
> recieve 50 pulses a second... how do I make sure they get this while
> still making decisions on input?
>
> It seems that in order to get 50 pulses/sec (or anything close to
> that) on a single-task processor (go basic stamp!) I would have to
> advoid long cycles..
>
> Here is a example program (not in pbasic, I don't know the syntax
>
[noparse][[/noparse]Non-text portions of this message have been removed]
The software answer is to do all your work in the 20mS or so that the
servos do not require pulsing. So if you need to send, say a 1.5mS pulse
you will do this:
1.5mS - pulse 1
* start 20mS
1.5mS - pulse 2
1.5mS - pulse 3
17mS - do whatever you like
Start pulsing servos again.
Another answer is to use a PAK-VIII to generate up to 8 pulses
independently. Have a look at t http://www.al-williams.com/pak8.htm and
also http://www.al-williams.com/servobot.htm for an example.
Al Williams
AWC
* Floating point math for the Stamp, PIC, SX, or any microcontroller
http://www.al-williams.com/awce/pak1.htm
>
Original Message
> From: GregT2 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=MtswqJ6YdN1H8_cG7BqjTfIBj6ayH7kCJVPWyAdlKe2zYVxfnuudKhFRbJDZ7u4ITjidoHfprL0FSLI]gregt@t...[/url
> Sent: Sunday, September 01, 2002 10:23 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] PWM question
>
>
> I'm very new to this basic-stamp stuff, but have been programing for
> quite some time (mostly web stuff, php+mysql, but some
> c,c++,c#,basic).
>
> My question is:
>
> Say I have 3 servos connected to my basic stamp. Each one needs to
> recieve 50 pulses a second... how do I make sure they get this while
> still making decisions on input?
>
> It seems that in order to get 50 pulses/sec (or anything close to
> that) on a single-task processor (go basic stamp!) I would have to
> advoid long cycles..
>
> Here is a example program (not in pbasic, I don't know the syntax
> well enough).
>
>
> 'init some vars here
> 'send pmw pluses
>
> MAIN: 'main loop
>
> pulse(time1,pina) 'pulse for first servo
> pulse(time2,pinb) 'pulse for second servo
> pulse(time3,pinc) '..
>
>
> for(i=0;i<1000;i++)
> {
> check for a input, need servo motors to stay in the same
> place/continue at the same speed...
>
> }
>
>
>
> Would it be ok to make a sub routine to update the servo's and then
> call this sub-routine inside every loop? Im confused -- maybe there
> isn't even an answer to my question.
>
> Thanks,
> Greg
>
> GOTO MAIN
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
> Subject and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>I'm very new to this basic-stamp stuff, but have been programing for
>quite some time (mostly web stuff, php+mysql, but some
>c,c++,c#,basic).
>
>My question is:
>
>Say I have 3 servos connected to my basic stamp. Each one needs to
>recieve 50 pulses a second... how do I make sure they get this while
>still making decisions on input?
>
>It seems that in order to get 50 pulses/sec (or anything close to
>that) on a single-task processor (go basic stamp!) I would have to
>advoid long cycles..
>
>Here is a example program (not in pbasic, I don't know the syntax
>well enough).
>
>
>'init some vars here
>'send pmw pluses
>
>MAIN: 'main loop
>
>pulse(time1,pina) 'pulse for first servo
>pulse(time2,pinb) 'pulse for second servo
>pulse(time3,pinc) '..
>
>
>for(i=0;i<1000;i++)
>{
> check for a input, need servo motors to stay in the same
>place/continue at the same speed...
>
>}
>
>
>
>Would it be ok to make a sub routine to update the servo's and then
>call this sub-routine inside every loop? Im confused -- maybe there
>isn't even an answer to my question.
>
>Thanks,
>Greg
>
>GOTO MAIN
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>
You could try this: order a ATTiny12 from Digikey. This is an AVR cpu
that has 8 pins. It is cheap - $2.75 and dead easy to program just hook
up some wire to your printer port and use WINAVR (freeware from the
internet). You can program them with RVK Basic, which is available on
the internet. I use them often to solve the problem of too many tasks.
chris in napa
I need another micro-controller.
If I have 2 available micro-controllers (2 basic stamps for instance)
to dedicate to the project, I can use one to do the decision making,
and the other to do the routine updating (PWM and such).
Another PWM topic, how sensitive is PWM to the 50 pulses/sec? Is all
that really matters ontime to offtime?
What im asking is how careful do I need to be regarding PWM cycle
times.
As to electronics -- I can't design circits but I generally have no
trouble breadboarding them. The cheaper the better, I have a large
supply of resisters capaciters and stuff (not that those are
expensive) and a limited amount of money to spend on IC's... I like
the idea of the 3 dollar one, and for the price I might just try and
figure out how to use it for my purpose.
Thanks for all the help
Greg
--- In basicstamps@y..., chris burns <mwalimu@s...> wrote:
> GregT2 wrote:
>
> >I'm very new to this basic-stamp stuff, but have been programing
for
> >quite some time (mostly web stuff, php+mysql, but some
> >c,c++,c#,basic).
> >
> >My question is:
> >
> >Say I have 3 servos connected to my basic stamp. Each one needs to
> >recieve 50 pulses a second... how do I make sure they get this
while
> >still making decisions on input?
> >
> >It seems that in order to get 50 pulses/sec (or anything close to
> >that) on a single-task processor (go basic stamp!) I would have to
> >advoid long cycles..
> >
> >Here is a example program (not in pbasic, I don't know the syntax
> >well enough).
> >
> >
> >'init some vars here
> >'send pmw pluses
> >
> >MAIN: 'main loop
> >
> >pulse(time1,pina) 'pulse for first servo
> >pulse(time2,pinb) 'pulse for second servo
> >pulse(time3,pinc) '..
> >
> >
> >for(i=0;i<1000;i++)
> >{
> > check for a input, need servo motors to stay in the same
> >place/continue at the same speed...
> >
> >}
> >
> >
> >
> >Would it be ok to make a sub routine to update the servo's and
then
> >call this sub-routine inside every loop? Im confused -- maybe
there
> >isn't even an answer to my question.
> >
> >Thanks,
> >Greg
> >
> >GOTO MAIN
> >
> >
> >To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@y...
> >from the same email address that you subscribed. Text in the
Subject and Body of the message will be ignored.
> >
> >
> >Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
> >
> >
> >
> You could try this: order a ATTiny12 from Digikey. This is an AVR
cpu
> that has 8 pins. It is cheap - $2.75 and dead easy to program just
hook
> up some wire to your printer port and use WINAVR (freeware from the
> internet). You can program them with RVK Basic, which is available
on
> the internet. I use them often to solve the problem of too many
tasks.
>
> chris in napa
people run every day without the use of a separate PWM coprocessor.
-- Jon Williams
-- Parallax
In a message dated 9/1/02 12:33:26 PM Central Daylight Time,
gregt@t... writes:
> So basically what you guys are saying is that if I want to drive PWM
>
[noparse][[/noparse]Non-text portions of this message have been removed]
the boe bot (thank you very much for makeing these available for
download by the way), and I've been trying to figure out how you can
guarentee 50 pulse/sec.
A PMW coprocsessor, while maybe un-necessary, frees stamp pins for
other things, guarentees a stable signal, and frees the stamp from
the actual pulse geneartion (should decrease the main loop cycle
time).
I think I am going to invest in one after I own my own basic stamp,
maybe even a math-type co-processor for accurate floating point and
trig math.
Maybe someday I'll be able to afford a boe-bot, until then I'm just
happy I have this basic-stamp on loan to play with! These things are
great, my only prior experience with the BASIC stamp is it's use in
the Innovation First robot controllers which I have been dealing with
every year in a anual robotics cometition.
Thanks for the input guys.
Greg
--- In basicstamps@y..., jonwms@a... wrote:
> No, that is not the case at all. We've sold thousands of BOE-Bots
that
> people run every day without the use of a separate PWM coprocessor.
>
> -- Jon Williams
> -- Parallax
>
>
> In a message dated 9/1/02 12:33:26 PM Central Daylight Time,
> gregt@t... writes:
>
>
> > So basically what you guys are saying is that if I want to drive
PWM
> >
>
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
flicker. I do not remember if the BS1 or BS2 was used. Anyone remember this
program?
www.glitchbuster.com
Good service and inexpensive shipping in the USA.
====================
I want to use a stamp2 circuit to drive a 12V 3.5 A pump motor.
My question is what do people use as a switch, a mechanical relay will not do
the trick, probably a transistor which can handle the current.
I would appreciate advice or preferable a source for a circuit
diagram/example.
Regards Uwe
[noparse][[/noparse]Non-text portions of this message have been removed]
othello159@h... writes:
> I would appreciate advice or preferable a source for a circuit
> diagram/example.
>
> Regards Uwe
>
>
The TIP122 will handle 5A at up to 100 volts. A high from the Stamp turns it
on, a low turns it off.
Sid Weaver
512K plug-in EEPROM.......
http://www.visualmuses.com/chipcircuit/index.html
[noparse][[/noparse]Non-text portions of this message have been removed]
My question is what do people use as a switch, a mechanical relay will not do the trick, probably a transistor which can handle the current.
I would appreciate advice or preferable a source for a circuit diagram/example.
Regards Uwe
The 2N3055 might work if properly biased and the transistor is not going to
pull more than about 1.75 amps. For the 2N3055 HFE can be as low as 20 or as
high as 70 with and IC of 4 amps (according to the data sheet).
If your load is 4 amps, the best case scenario (hfe 70) results in a required
base current from the stamp of about 57 mA.
If memory serves me correctly, the BS2 can source a maximum of about 25mA for
one output pin.
You could make a darlington with a second transistor.......but in my opinion,
not worth the effort when there is a logic level mosfet such as the IRL520.
My suggestion is to go to www.glitchbuster.com and get a handfull of IRL520
LOGIC LEVEL mosfets for 0.67 cents each. Shipping in the USA is very cheap,
less than $2.
This is a no brainer easy solution.
Ken
=============================
Would a 2N3055 work? I happen to have a few of those around...
73 Uwe
[noparse][[/noparse]Non-text portions of this message have been removed]
> In a message dated 5/22/2004 5:14:19 PM Eastern Daylight Time,
> othello159@h... writes:
>
>
> > I would appreciate advice or preferable a source for a circuit
> > diagram/example.
> >
> > Regards Uwe
> >
> >
>
> The TIP122 will handle 5A at up to 100 volts. A high from the Stamp turns it
> on, a low turns it off.
>
> Sid Weaver
Would a 2N3055 work? I happen to have a few of those around...
73 Uwe