Resistor values. Do they look OK?

I am trying to control the speed of a motor using a Picaxe 08M connected to an Electronic Speed Control (ESC). The ESC responds to pulses the same way a servo does. Below is the code. And I attached the circuit schematic.
My question is about the values of R3 and R4. I am not sure if they are correct for what I am trying to do.
Code:
#picaxe 08M 

				'Pin assignement
Symbol Volt_in= Input2
Symbol Ser_out= 1
Symbol Pulse_out= 4
				'Variables
Symbol Volt_read = W0
Symbol Signal = W1
; *******************************

High 1						' Tx Pin is idle for some time
  	Pause 4000				' wait for  LCD to boot
   	SerOut 1, T2400, ("?G420")	' configure LCD as 4 X 20
   	SerOut 1, T2400, ("?f")		' clear the LCD and home the cursor
   	SerOut 1,T2400, ("?B70")		' Set backlight
   	Pause 100

Main:
readadc10 2,Volt_Read
w1=w0 Min 75 Max 225
Pulsout 4,Signal

SerOut 1, T2400, ("?f")
Serout 1,T2400, (#Signal)
Goto Main
 

Attachments

Last edited:

sghioto

Senior Member
Marmitas,

Not really. You don't need to use "readadc10" if the value is going to be between 75 and 225. With a 5 volt supply a reading of 75 is about 1.5 volts and 225 is about 4.5 volts. In order to use the full range of the pot the voltage across the pot should equal 4.5 - 1.5 or 3 volts. I would add a little more just to be sure to cover the range due to tolerances of the resistors in the divider.
Lets make it 4.6v - 1.4v or 3.2 volts. You will also need to add another resistor ( let's call it R5) in series between ground and the pot. Since we know the voltage across the pot needs to be 3.2 volts we can figure the current then calculate the values of R3 and R5.
OK, 3.2v / 50,000 ohms = .0000640 amps. The voltage across R5 is 1.4 volts and the voltage across R3 is .4 volts. So R5 = 1.4 /.000064 , which = 21875 ohms and R3 = .4 /.000064 which = 6250 ohms. A 22K for R5 and 6.2K for R3 will work nicely. Hope this will help.

Steve G.
 

Attachments

BeanieBots

Moderator
I'd not bother with R3 & R5 and would do the scaling in code.

readadc N,w0
w0=w0*10/17+75

50k for R4 is a bit on the high side. Only JUST falls within the PIC datasheet maximum input impedance. Using a 10k pot would be better and less prone to noise if there is much lead length on any of the POT terminals.
 

westaust55

Moderator
I concur with Beaniebots.

While even I have a 20 kΩ pot across 5V to 0V in my own PICAXE rig,
in theory a 10 kΩ pot is more in line with the max source impedance of kΩ into a PIC chip ADC input in accordance with the datasheets.
A maximum source impedance of 10 kΩ is recommended for the analog sources.
 

papaof2

Senior Member
If you look at the two "halves" of a linear pot as two parallel resistors, the maximum resistance of a 20K pot would be 10K at the center of rotation and any other position would be less than 10K (1/4 turn would be 5K in parallel with 15K).

John
 

BeanieBots

Moderator
papaof2 is correct.
However, I'd still suggest 10k for two reasons.
1. 10K source impedance is the MAXIMUM, not the optimum.
2. 10k is the most common value and hence most likely to be the cheapest.
 

sghioto

Senior Member
Well I agree BeanieBots formula "w0=w0*10/17+75" is an elegant solution to the problem I still prefer the resistor divider using the code:

readadc N, b0
b0 = b0 min75 max225

Both codes will produce 150 steps but the resistor divider approach is more linear. Since the code "w0=w0*10/17+75" converts 256 steps to 150 about 40% of the ADC readings are duplicated. Depending on the linearity of the pot and the ESC this could make some difference.
Marmitas, if you decide to use the resistor divider then I would use a 10K linear pot as suggested. This will change R3 to 1.6K and R5 to 4.7K both standard 5% values

Steve G.
 

BeanieBots

Moderator
I don't want to get into a "my solution is better than yours" debate but,
both will be equally linear.
If the POT does have non linearity, a division will actually HELP linearise it.

If the two end resistors are not absolutely correct in value, then either the MAX/MIN will waste the lower and/or higher range of the POT or the full 75 to 225 range will not be achievable.
 
Top