controling a 4 potentiometers with a propeller
Sigma X
Posts: 38
hello everyone I am at my ropes end and I need help
I have the book "programming the propeller in spin"
I've gotten to the experiment of·using a pot to control a servo
I programmed the code word for word but no luck
has anyone attempted this if so please help
·
I have the book "programming the propeller in spin"
I've gotten to the experiment of·using a pot to control a servo
I programmed the code word for word but no luck
has anyone attempted this if so please help
·
Comments
www.mhprofessional.com/getpage.php?c=computing_downloads.php&cat=112
hope that helps,
Mark
www.mhprofessional.com/downloads/products/0071716661/0071716661_SPIN_Programs.txt
www.mhprofessional.com/downloads/products/0071716661/0071716661_Wiring_Diagrams.pdf
Did you check out the wiring diagrams link? I think it shows how to hook up a pot and maybe even it has the exact figure for your test, but I'm not sure because I don't own the book.
www.mhprofessional.com/downloads/products/0071716661/0071716661_Wiring_Diagrams.pdf
cannot control a servo through a pot
Then set up the simple circuit for using the Prop to move a servo, and get that working.
Once you understand both of those, you can use the pot to control the servo with just some small changes to the code.
READING A POTENTIOMETER
This routine ready a 10K pot with a 10 mfd cap
This routine is what is used in the utilities to read the pot
Pot is always read from the same line
}}···
CON·································································
· _CLKMODE=XTAL1+ PLL2X········ 'The system clock spec
· _XINFREQ = 5_000_000········· 'Crystal spec
· PotLine·· = 19········· 'line the pot it on······· <<<<<<<<<<<<<<
Regards
Gerry
There is a whole section in the book devoted to reading A/D devices, the 3202 and the 3208
The book also explains how to read a potentiometer using R C decay as alluded to by Gerry
Using the 3202/8 is more accurate in that you can read them to 12 bits
Put it all together for the results you need.
Harprit
Sigma,
look at page 22 of the link I have posted here for how to hook up a pot to a Prop. It is entitled "Figure 16-1, Circuitry for reading a potentiometer with a Propeller chip."
Click on this link to read the wiring diagrams and see page 22:
www.mhprofessional.com/downloads/products/0071716661/0071716661_Wiring_Diagrams.pdf
If you still find that material irrelevant to your problem, then perhaps you are talking about a different book???
it's just not working the ciricut the schematic it's all right
but none of this works
I even tried using the formula on 24-1
still no luck
Post Edited (Sigma X) : 7/18/2010 6:28:31 PM GMT
Can you post of photo of your set up?
Do you have a multimeter/voltmeter to check your connections, starting with the power supply and moving through the system? If you're using a battery, be sure it's not dead.
the servo moved sort of it kinda moved like a clock ticking and whatnot
I still cannot change direction but this is progress right?
it turns all the way clockwise when I turn the pot nothing happens
I hope this info helps
To post your code, you need to copy it and then paste it between two code tags. The first tag looks like [noparse][[/noparse] code ] except you need to remove all the spaces. And the ending tag looks like [noparse][[/noparse] / code ] except, again, be sure to remove all the spaces.
I'm just making a wild guess here, but it sounds like maybe you haven't worked your way through all the basic experiments before attempting this pot-controlled servo experiment. Or perhaps you didn't sufficiently absorb the concepts provided by those earlier lessons. Might it help for you to go back and re-do some of those earlier projects?
hope that helps.
In this program the 3202 is on lines 24 to 27 of the prop. This is covered earlier in the book on the 3202
and remains connected at all times to provide support for the Utilities OBJ in all subsequent experiments.
However if you don't read the book and do the exercises you are going to have problems again and again.
Good luck and keep reading.
Where is the pic you promised, where is the code?
Harprit
RC_ServoPosition.spin
Propeller Tool Version 1.2.6
Chapter 24 Program 02·····
READING A SERVO'S POSITION· uses pin 23
This program allows you to tie the signal sent to an
R/C servo to the position that it goes to.
Connections
White· P23 signal from Prop
Red 5 volts
Black ground
}}···
CON············································································
· _CLKMODE=XTAL1+ PLL2X········ 'The system clock spec
· _XINFREQ = 5_000_000
·· outPin· =23·················· 'line the servo is on
··································
VAR···························· 'these are the variables we will use.
· long ServoPos················ 'The program will read this variable from
······························· 'the main Hub RAM to determine the
······························· 'servo signal's high pulse duration
· long stack [noparse][[/noparse]15]·············· 'space for Cog for LCD
· long stack2[noparse][[/noparse]50]·············· 'space for Move Motor Cog
· long pcount·················· '
OBJ····························· 'These are the methods we will need for our calls
· LCD· : "LCDRoutines4"········· 'for the LCD methods
· UTIL : "Utilities"············ 'for general methods, pot
··
PUB Go·························· 'main cog
· dira[noparse][[/noparse]outPin]~~···················· 'set direction for amplifier··············
· cognew(MoveMotor(outPin),@Stack)·· 'start a new cog and run the MoveMotor method
································ 'on it and output pulses on Pin 23·
································ 'The new cog that is started above continuously
································ 'reads the "position" variable as it's changed
································ 'by the example Spin code below
· cognew(cog_two, @stack2)······ 'start new cog for the LCD·························
· repeat························ 'this is the Cog's main loop·································································································
··· pcount:=UTIL.Read3202_0····· 'get the pot reading from the utilities
··· ServoPos:=7200+pcount*4····· 'calculate position count
·
···
Pub cog_two························ 'set up and run the LCD············
· LCD.INITIALIZE_LCD··············· 'initialize the LCD
· repeat··························· 'LCD loop················
··· LCD.POSITION (1,1)············· 'Go to 1st line 1st space
··· LCD.PRINT(STRING("Pot Pos="))·· 'Potentiometer position ID
··· LCD.PRINT_DEC(Pcount)·········· 'print the pot reading·······························································
··· LCD.SPACE(2)··················· 'erase over old text······
·····················
PUB MoveMotor(Pin)|LowTime,period·· 'method to toggle the output line, set
··································· 'up first
· dira[noparse][[/noparse]Pin]~~······················ 'Set the direction of "Pin" to be an output
· ctra[noparse][[/noparse]30..26]:=%00100············· 'Set this cog's "A Counter" in single
··································· 'ended NCO/PWM mode (where frqa always············································
··································· 'accumulates to phsa and the Apin output
··································· 'state is bit 31 of the phsa value)·······························
· ctra[noparse][[/noparse]5..0]:=Pin·················· 'Set the "A pin" of this cog's "A Counter"
··································· 'to be "Pin"··········································
· frqa:=1·························· 'Set this counter's frqa value to 1 (so 1
··································· 'will be added to phsa on each clock pulse)
· ServoPos:=0······················ 'Start with position=0 (until the position
··································· 'value is changed by another cog)················
· LowTime:=clkfreq/60·············· 'Set the time that the pulse will be low
··································· 'to 16ms = 1/60 secs
· period:=cnt······················ 'Store current value of the system counter
· repeat··························· 'line toggling routine.
··· phsa:=-ServoPos················ 'Send a high pulse for "position" number of
··································· 'clock cycles. Note negative sign
··· period:=period+LowTime········· 'Calculate what system clock's value will
··································· 'be at the end of this cycle's period
··· waitcnt(period)················ 'Wait for the system counter to reach the
··································· '"period" value (end of cycle)
[noparse][[/noparse]/code]
above is the code i'm using I went through the entire book however I didn't do any experiments until this one
btw my camera is busted so the setup pic will come a bit later maybe on tuesday...i hope
Post Edited (Sigma X) : 7/18/2010 11:09:45 PM GMT
The LCD has to be in place among other things if you want to see what is happening in the program
They are made functional in preceding programs that you have skipped
These preceding programs also show you how to set up the 3202 etc. You need this to read the pot.
Go do all the program exercises in order and it will all work
This is a powerful and complicated system. It will take some discipline but you can do it.
Its like a geometry proof, you cant skip some steps and still get it!
Harprit.
Sigma,
I cleaned up your code tags by separating them from the body of your code. I think my browser could not understand your tags because you had them running into the body of the code (much like the way you write, BTW. )
Well, maybe the best thing to do is back up a little bit and play with some of the simpler set-ups that are presented earlier in the book. It probably won't take you long and it sounds like you can build off of those simple concepts to achieve what you're trying to do.
Let us know how you do.
Good luck!
the servo moved to one end because the pot was read as having an infinite resistance
or being pegged at 4095.
Harprit.
ElectricAye
Thanks for getting to this before I noticed that it was about my book.
H
with that stated I may have to start over mainly with the book I have it's probally too dificult to start
out with I just thought it'll be easy due to having skill with the basic stamp
If you have previous experience with the Stamp, then you'll have no problem learning how to work with the Propeller. But the Propeller is a different animal, so take your time, be patient with yourself, and go step by step. Also, don't be afraid to post your questions on this forum. People on here have helped me tremendously.
cheers,
Mark
in doing so I found somthing
1)It wasn't a hardware error or mostly the propeller experimental board was built right on my first try but
alot of equipment was too old and faulty·mainly the servos
2)It was a power problem this thing takes tremedous juice to run my 9v batteries we're dead·enough not to be found sometimes
once I took my time and inspected things the blink a led circut worked liked a charm
and learning the spin language is really really simple thanks everyone for your help and support