View unanswered posts | View active topics It is currently Thu Dec 25, 2014 1:59 am






Reply to topic  [ 5 posts ] 
Mimic an analog output 
Author Message
Rookie

Joined: Sun Oct 14, 2012 7:40 am
Posts: 3
Post Mimic an analog output
I am trying to output the equivalent of an analog 0-5V signal from a Motor port using RobotC. I realize that the NXT outputs a PWM duty cycle. I was using the following command:

motor[motorA] = Throttle; // Outputs voltage to port A indicating Throttle level

The voltage that I read across the black and white wires connected to port A is by no means proportional to the value of the variable Throttle. I was successful at doing this in NXTG. I believe there is a way of doing this in RobotC. Conversly, I could place a low pass filter in the form of an RC circuit on my black and white wires. I do not have any idea what sized resistor and capacitor I should use if I do a hardware solution.

I welcome feedback from anyone who has expereince with this.

Thanks,
Blair


Tue Feb 12, 2013 8:53 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Mimic an analog output
A couple things:

First, you said you recognize that the output is PWM, which is correct. However, you didn't mention that it's 9v (or whatever voltage the batteries are).

Second, you will need to disable any PID related control, as if it was an RCX motor.

Third, motor port A is backwards from the other two ports. Brake is ++ Forward is +- and Reverse is -+. It will probably appear that the PWM is inverted compared to the "power level", that is to say, a 10% power setting will likely output as 90% high, and 10% low (since the polarity is inverted). Motor ports B and C are more how you would expect.

I would recommend you use a DAC instead of a motor port. You could actually get a clean 0-5v.

_________________
Matt


Tue Feb 12, 2013 11:15 pm
Profile WWW
Rookie

Joined: Sun Oct 14, 2012 7:40 am
Posts: 3
Post Re: Mimic an analog output
Matt,

Thanks for the response. I like the idea of using a DAC for a consistent 0-5 V output. Are you referring to an addition piece of hardware that plugs into the NXT to provide a Digital-to-Analog output? If so, can you reference me to something I can buy or build? Or is this a software solution. If so, can you point me to some code?

Your help is appreciated.
Cheers,
Blair


Wed Feb 13, 2013 9:33 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Mimic an analog output
The NXT doesn't have a DAC (at least not that you can access). I recommend using something like the PCF8591, which is an 8-bit 4 channel ADC and 1 channel DAC. mindsensors.com sells a kit for the NXT, which should make it really easy to use.

_________________
Matt


Thu Feb 14, 2013 3:36 pm
Profile WWW
Rookie

Joined: Sun Oct 14, 2012 7:40 am
Posts: 3
Post Re: Mimic an analog output
Matt,

Thanks for the insight. I have been reading up on I2C to gain a better understanding of your recommendation. This will develop me to the next level. I am ordering the kit you recommended. I can visualize a broad set of solutions using this approach.

Cheers & Thanks,
Blair


Sat Feb 16, 2013 11:36 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.