simple way ...
Hi, Malc
Try this:
TEMP var WORD
Main:
ADCIN 0, DUTYVAR[0] ; if having more channels add ADCIN 2, DUTYVAR[2] etc
TEMP = DUTYVAR[0] * DUTYVAR[0] / 256 '********************
IF DUTYVAR[0] < 10 THEN ' 10 = value for a neat motor start , if needed !
DUTYVAR[0] = 0
GOTO Jump0
ENDIF
DUTYVAR[0] = TEMP MAX 10
Jump0:
ADCIN 1, DUTYVAR[1]
TEMP = DUTYVAR[1] * DUTYVAR[1] / 256 '********************
IF DUTYVAR[1] < 10 THEN ' 10 = value for a neat motor start ,if needed !
DUTYVAR[1] = 0
GOTO Jump1
ENDIF
DUTYVAR[1] = TEMP MAX 10
Jump1:
GOTO Main ; program simply loops round reading ADC and sending corresponding PWM out
That what I use for my boat speed controllers ... works really fine !!!
Regards
Alain
PS: here is the original
'************************************************* *****************************
'Mise à l'echelle 0 - 255 de la sortie PWM pour 0 - 96 % de la course
'************************************************* *****************************
' 265 = 255 / 0.96 ... CQFD
'************************************************* *****************************
'Moteur Gauche
'************************************************* *****************************
EcartGazG = ( ABS ( PulsGazG - MidGaz)) ' for fwd/rev on the same stick
IF EcartGazG < 55 THEN 'Center Deadband
PowerG = 0
GOTO MotD
ENDIF
dummy = EcartGazG * 265
PowerG = DIV32 CourseGaz
PowerG = (PowerG + 1 ) MIN 255 ' 255 value as MAXI for PWM
'************************************************* *****************************
'Variation exponentielle
'************************************************* *****************************
dummy = PowerG * PowerG
PowerG = DIV32 255
'************************************************* *****************************
'Puissance mini appliquee au moteur - démarrage franc ( 20/255 )
'************************************************* *****************************
PowerG = PowerG MAX 20
Last edited by Acetronics2; - 22nd April 2007 at 18:27.
************************************************** ***********************
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 " !!!
*****************************************
Bookmarks