PDA

View Full Version : help!!!!



lokanand
- 8th May 2006, 11:13
hi,
i am a newcomer to PIC basic pro.i would like to know what scale values {while using pot command } are appropriate for a 200k pot, and 0.1microF.
bye

Archilochus
- 8th May 2006, 21:04
Hi lokanand,
I don't think there are any specific values for SCALE - it's sort of a try it and see kind of thing. There is a bit of code in the PBP manual for calibrating the SCALE value - give it a try.

Arch

sayzer
- 9th May 2006, 07:05
Also, 200k pot with 100n is not a good combination.

As Archilochus said, check the manual.

Play with 50k, 5k and 10n, 100n.


-----------------------------------

Melanie
- 9th May 2006, 07:16
I favour 100n for the POT Capacitor (same one's I use for decoupling sprinkled around the PCB - saves loading another component reel onto the board stuffing machine). With a 10K variable, the scale value is about 95.

champion
- 9th November 2006, 16:33
does this mean a 100nanoFarad???

paul borgmeier
- 9th November 2006, 16:44
yes
100 nF = 0.1 uF

champion
- 9th November 2006, 17:58
Thanks!!! BTW, I am trying to execute the code supplied in the PICBasic manual, but it doesn't seem to work.

This is the code in the manual.

B0 Var Byte
scale Var Byte

For scale = 1 To 255
POT 0, scale, B0
If (B0 > 253) Then calibrated
Next scale

Serout 2,0,[" Increase R or C.", 10,13]
Stop

calibrated:
Serout 2,0,[" Scale= ",# scale, 10,13]

This is my modified code:

B0 var byte
scale var byte
LED var PORTB.1
Potpin var PORTB.2

for scale = 1 to 255

LCDout $FE, 1, "calibrating", $FE, $C0, "Scale=", DEC scale, "B0=", DEC B0
pot Potpin, scale, B0
If (B0 > 253) then calibrated
next scale

Lcdout $FE, 1, "Increase R or C"
stop
calibrated:
lcdout $FE, 1, "Scale=", scale

As you can see, I have the pot connected to PORTB2.

When I run the code, I can see the scale and B0 incrementing on the LCD, however, before B0 or scale reaches 255 it starts over from scale=0 & B0=0.

Anyone have experience with this???

I know it's possible to do this manually but I would like to do it with automation because I will need to calibrate the scale for several different pots in the future. Thanks!!!

sayzer
- 9th November 2006, 19:42
At first glance, before other possibilities, "then calibrated" will work like GOTO; not like GOSUB.

I would suggest that you use "calibrated" as a subroutine with a "return" and change all "then calibrated" to "then GOSUB calibrated".

Then we can talk about the rest of the code.

------------------------

champion
- 9th November 2006, 20:20
Thanks sayzer...I changed it to a gosub, and it freaked out because when it returns to the loop in still increments scale. So I tried goto calibrated and the LCD at least shows scale=, but it says "scale=r" WTF?

Here's what I've got. BTW, thanks again for all of your help. I'm already miles ahead just from reading your posts.

B0 var byte
scale var byte
LED var PORTB.1
Potpin var PORTB.2

for scale = 1 to 255

LCDout $FE, 1, "calibrating", $FE, $C0, "Scale=", DEC scale, "B0=", DEC B0
pot Potpin, scale, B0
If (B0 > 253) then
goto calibrated
endif
Pause 1000
next scale

Lcdout $FE, 1, "Increase R or C"
stop
calibrated:
lcdout $FE, 1, "Scale=", scale

end

paul borgmeier
- 9th November 2006, 20:30
Possibly you want

lcdout $FE, 1, "Scale=", DEC scale

when you jump out, otherwise you get the ASCII equivalent of scale?

champion
- 9th November 2006, 20:33
doh! Thanks. Works great! Here's my final code for others to use as reference.

B0 var byte
scale var byte
LED var PORTB.1
Potpin var PORTB.2

for scale = 1 to 255

LCDout $FE, 1, "Wait for Calibration", $FE, $C0, "Current Scale=", DEC scale
pot Potpin, scale, B0
If (B0 > 253) then
goto calibrated
endif
next scale

Lcdout $FE, 1, "Increase R or C"
stop
calibrated:
lcdout $FE, 1, "Use Scale=", DEC scale, $FE, $C0, "Have a nice day"
high led
end