Acetronics,
I would like to apologize for the things I said.
You were right and I was wrong. I missed some parts and behaved impolite.
I also sent you a private message to apologize.
Sayzer
---------------
Acetronics,
I would like to apologize for the things I said.
You were right and I was wrong. I missed some parts and behaved impolite.
I also sent you a private message to apologize.
Sayzer
---------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
[QUOTE=sayzer]Acetronics,
I would like to apologize for the things I said.
...
Hi, Sayzer
that's kind from you ,
the only important thing is you've learnt something useful ... I don' like this teaching method ... but I'm pretty sure you will always remember about PULSOUT resolution.
a good joke is my favourite method for students to keep things in mind.
That's the only real important thing....; may be ... life respect too, but it's not the right place to discuss it here.
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
I've tried all the tips you guys gave, and have also been trying any and all PicBasic servo control code I could find on the net, but something is still not right. I've tried four different servos that I know to be functional. I've tried a 16F690 and a 16F628A, with the internal oscillator and with an external 4MHz crystal. I've tried changing the pulsewidths and pauses to every reasonable and many unreasonable numbers. I've switched breadboards. I'm shopping around for a goat to sacrifice to the PIC.
Here's what I'm trying to use now, with a 16F628a:
trisb = 0
cont var byte
cont = 0
led var PORTB.1
hither:
low led
for cont = 0 to 50
pulsout PORTB.0,110
pause 18
next cont
goto yon
yon:
high led
for cont = 0 to 50
pulsout PORTB.0,190
pause 18
next cont
goto hither
It is a slightly modified version of some code from the rentron site, which was meant for a 16F84. My include file (not the whole thing of course) looks like:
device pic16F628A, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
My LED does flash convincingly, but still my servo heads to one extreme and stays there. This is keeping me awake at night now. What mistakes might I still be making? Does anyone know of an example of a working servo controller written in PicBasic, including a circuit diagram and not intended for a 16F84? I just need something functional to build on.
You're probably sick of this thread by now, but any help would be appreciated.
Try this code.
Schematic and code are also attached.
------------------------------------------------------------------------
@ DEVICE intrc_osc, MCLR_OFF,WDT_OFF,PROTECT_OFF
DEFINE LCD_EREG PORTA
' Set LCD Enable port
DEFINE LCD_EBIT 7
' Set LCD Enable bit
TRISA=%00100000
' RA5=Input, Rest= Output
TRISB=%01100001
' RB6, RB5, RB0 = Input, Rest=Output
'--------Assign name to ports---------------
potvar var portb.0
'Pot is connected to RB0.
servo var portb.3
'Servo is connected to RB3.
Button1 var portb.5
'Button1 is connected to Portb.5 and increases the frequency.
Button2 var portb.6
'Button2 is connected to Portb.6 and decreases the frequency.
'---------Variables-------------------------
pulse var byte
'Variable to hold Pot value for servo Position
freq var byte
'Variable to hold Button1 and Button2 adjustments for Frequency
'--------Initial Setup----------------------
Freq=18
'Initial Frequency
'--------Main Loop-------------------------
loop:
IF button1=0 then freq=freq+1
'Incr freq
IF button2=0 then freq=freq-1
'Decr freq
IF freq>30 then freq=30
'Max. Low freq
IF freq<5 then freq=5
'Max. High Freq
pot potvar,255,pulse
'Read pot and store the value in pulse variable
If pulse>240 then pulse=240
'Max. Pulse 240mS
IF pulse<60 then pulse=60
'Min. Pulse 60mS.
pulsout servo,pulse
'pulsout the stored pot value (pulse) to servo pin.
pause freq
lcdout $fe,1,"Pulse:",#pulse
LCDOUT $fe,$c0,"Freq:",#freq
goto loop
--------------------------------------------------------------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Hi, Eris
Seem strange ...
There's one last thing we didn't had a look to : Your supply !!!
Could you describe it or better send a scheme.
On my side, I try your code on my 628 R/C testboard ... just to be sure!.
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi, Eris
Bad news ... I copied and pasted your code, just changed portB N°s as required here ... put a 6LR1 cell ( there's a regulator on the board !!! ) and a futaba servo.
Every thing goes as you programmed it : the led blinks and the windscreen wiper does its job ...
The problem is not ( no more ... humour ) in your code ...
So, What to do ??? ...
First verify your servo supply ( good common ground w/Pic ... enough current to feed the servo ...)
Second verify the signal lead of the servo ... servo behaviour smells no received signal !!!
In that way I would recommend you !!! SOFORT !!! to add a 1k resistor between Portb.0 and your servo connector.
I keep the line
Alain
Last edited by Acetronics2; - 27th February 2006 at 13:12.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Many thanks to you smart and helpful people - I've finally got this working. I was spending all my time checking and rechecking the code, and it seems that the problem (or the final one, anyway) was that the servo and PIC didn't have a common ground. And here I thought that breadboard with two separate bus strips would be *helpful*.
I did, at least, pick up a lot of PicBasic tips while working on this, so I should be better equipped for the rest of my project. Thanks again!
Bookmarks