Hi, I would like to drive my motors using pwm and read voltage input
using anavolts from my IR sensor.
I am using rabbit 4000 and rcm 4100.
My problem is, when pwm is running (i.e. fwd function below),
anainvolts doesnt seem to work. How can I work around this that is be
able to drive the motor and receive voltage reading?
the following is the code:
#class auto
#use RCM41xx.LIB
#ifndef ADC_ONBOARD
#error "This core module does not have ADC support. ADC programs
will not "
#fatal " compile on boards without ADC support. Exiting
compilation."
#endif
void fwd()
{
// pwm_set(1, (int)(0* 1024.0), PWM_USEPORTE); //PE5 hi
// pwm_set(0, (int)(1 * 1024.0), PWM_USEPORTE); //PE4 hi/low
printf("fwd\n");
pwm_set(1, (int)(0* 1024.0), PWM_USEPORTC); //PE5 hi
pwm_set(0, (int)(1 * 1024.0), PWM_USEPORTC); //PE4 hi/low
printf("fwd\n");
}
void stop()
{
pwm_set(1, (int)(0* 1024.0), PWM_USEPORTE); //PE5 hi
pwm_set(0, (int)(0 * 1024.0), PWM_USEPORTE); //PE4 hi/low
printf("stp\n");
pwm_set(1, (int)(0* 1024.0), PWM_USEPORTC); //PE5 hi
pwm_set(0, (int)(0 * 1024.0), PWM_USEPORTC); //PE4 hi/low
printf("stp\n");
}
main ()
{
auto unsigned int gain;
auto float voltRead;
brdInit();
gain = 0;
fwd();
while (1)
{
costate
{
voltRead = anaInVolts(2,gain);
printf("%.3f V\n",voltRead);
waitfor(DelaySec(2));
}
costate
{
if (voltRead <20)
{
printf("obstacle ahead\n");
waitfor(DelaySec(3));
}
}
}
}// end main
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )