Since you arrived at the same conclusion.
Does it really matter how you got there?
Factoring polynomials is more of an Art.
There's almost always more than one way to get there.
Nice work Walter!
<br>
Since you arrived at the same conclusion.
Does it really matter how you got there?
Factoring polynomials is more of an Art.
There's almost always more than one way to get there.
Nice work Walter!
<br>
DT
Hello
Thanks for all the good tips and trick here it has helped me a lot. I think this is the right tread to put this.
I am making an analogue Amp Instrument with a Servo with an arrow that shows the +10 to -10 Amp. Its for an old style motorbike.
I have an Allegro Current Sensor, represented by Pot ASC714. The ASC714 Zero IN current give an output of 2.5V. I want the span to be between +10 Amps to -10 Amps. Each Amp out of the sensor =66mV. The output is:
+10A=3.16V=255
0A=2.5V=127
-10A=1.84V=0
I use only 8bit A/D and a PIC16F887.
I have set Vref+ to 3.16V and Vref- to 1.84V
At first sight it look that its working fine. But after some jogging with the pot it sometimes count up instead of down and vice versa. I think it has something with the Div32 to do and that i overflow it but cant figure out how to correct this.
Thankful for all solutions
Ole Thronborg
'************************************************* ***************
'* Name : Amp887.BAS *
'* Date : 17/3/2011 *
'* Notes : Read ASC714, Out LCD +-10A and move Servo *
'* Show value in bit and Amp on LCD display
'* For PIC16F887 *
'* For standard servo settings 1-2mS set LOW_servo con 100 *
'* and HIGH_servo CON 200 *
'************************************************* ***************
'Define OSC and ADC
DEFINE OSC 4 ' Set internal Oschillator to 4Mhz
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 2 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
' Define LCD pins
Define LCD_DREG PORTD 'LCD data port
Define LCD_DBIT 0 'LCD data starting bit 0 or 4
Define LCD_RSREG PORTD 'LCD register select port
Define LCD_RSBIT 4 'LCD register select bit
Define LCD_EREG PORTD 'LCD enable port
Define LCD_EBIT 5 'LCD enable bit
TRISA = %00001101 ' RA0 = A/D input
ADCON1.7 = 0 ' RA.1 = +Vref, Set PORTA analog and left justify result
ADCON1.5=1 ' Set Vref- to pin 5
ADCON1.4=1 ' Set Vref+ to pin 4
PORTb.6 =0 ' Prepare RB0 for high-going pulseout
ANSEL = %00001101 ' Set PORTA.2 analog, rest digital
'ANSELH = %00000000
' Variables
outpuls VAR byte ' Variable for the calculated puls out in mS
POT_POS VAR BYTE ' Pot position CC=0, CCW=255
ampdum VAR Word ' A dummy to canculate big values
amp var word ' Calculating Ampere
LEFT CON 90 ' Left Stop position 0.70mS
RIGHT CON 163 ' Right Stop position 2.1mS
'Pause 700 ' Wait for LCD to start
MainLoop: ' The Loop start here!
ADCIN 0,POT_POS ' Read A/D channel 0 to variable SVO_POS
IF POT_POS>127 then ' Check if positive
ampdum=(7874* (POT_POS-128)) ' Then calculate the dummy
amp= div32 100 ' Let amp get the dummy value
else
ampdum=(7874 * (127-POT_POS)) ' Now it must be negative Amp so calculate
amp= div32 100 ' Let amp get the dummy value
endif ' End of test if Amp negative
'Output to LCD
Lcdout $fe, 1, "POT_POS= ", #POT_POS ' Display POT Valu between 0-255 on line 1
IF POT_POS>=127 then ' Check if + Ampere Else goto - Ampere
LCDOut $fe,$C0, "AMP= ",DEC (amp/1000),".", DEC1 amp' Display pulswith in mS on line 2
else
LCDOut $fe,$C0, "AMP= -",DEC (amp/1000),".", DEC1 amp' Display pulswith in mS on line 2
endif
'outpuls =100+(POT_POS *100/255) 'Calculate the outpuls in mS
'IF outpuls < LEFT THEN outpuls = LEFT ' Stop if puls shorter than constant LEFT
'IF outpuls > RIGHT THEN outpuls = RIGHT ' Stop if puls shorter than constant RIGHT
' Span 100 gives 100+100 = 200=2mS 150 is center
'PULSOUT portb.6 ,outpuls ' Move servo on pin
'PAUSE 20 ' Constant 20mS pulses(low) between outpuls
'GOTO MainLoop ' Forever
End
![]()
Bookmarks