NXT Sensor Input Ports
-
- Posts: 7
- Joined: 22 Jul 2011, 14:10
NXT Sensor Input Ports
Has anyone ever tried using the analog and digital inputs on the same port at the same time?
-
- Posts: 252
- Joined: 22 Oct 2010, 20:05
- Location: The United States of America
- Contact:
Re: NXT Sensor Input Ports
It is possible, and can be achieved quite easily with a multiplexer. A multiplexer of your description can be bought here.
-Hayden
Re: NXT Sensor Input Ports
I guess he might be thinking more of using a port splitter for A & D.
Although I never tried it, it may be sth like
(I do not know the NXC sensor commands by heart, I always have to look into the NXT docs to see how to do it)
Although I never tried it, it may be sth like
Code: Select all
int myvalue;
while (true) {
SetSensor(port, SensorLightActive); // or how ever this is in NXC for NXT 1.0 Light Sensor
Wait(10); // never tried how long to wait to initialize the sensor to analog
myvalue=SensorValue(port); // or how ever this is in NXC
SetSensor(port, SensorLowSpeed); // or how ever this is in NXC
Wait(10); // never tried how long to wait to initialize the sensor to i2c
myvalue=SensorUS(port); // or how ever this is in NXC for US sensor
}
-
- Posts: 7
- Joined: 22 Jul 2011, 14:10
Re: NXT Sensor Input Ports
Yes Helmut, I am thinking along the lines of port spliters. Running a digital and an analog sensor off one port to save ports. I just started with mindstorms and was woundering if this has been tried using G Blocks to give you more ports with out multiplexing. Thanks Andy
Re: NXT Sensor Input Ports
Andy,
I'm sure this works with cascated G-blocks by the same way.
Just try it out, you can't damage anything.
Be sure that your port splitters support multiplying both analog and digital lines!
I'm sure this works with cascated G-blocks by the same way.
Just try it out, you can't damage anything.
Be sure that your port splitters support multiplying both analog and digital lines!
Re: NXT Sensor Input Ports
What you cannot do with the standard NXT firmware is configure a port as a lowspeed (I2C) or highspeed (RS485) port and read analog sensor values while the port is configured for that type. The firmware just doesn't bother to copy over the AD raw value from the AVR into the Input module IOMap structure if a port's SensorType is LOWSPEED, LOWSPEED_9V, or HIGHSPEED. Today I added a couple of lines of code to the enhanced NBC/NXC firmware so that it does copy over the ADRaw value even when the sensor type is one of these three values.
John Hansen
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
-
- Posts: 252
- Joined: 22 Oct 2010, 20:05
- Location: The United States of America
- Contact:
Re: NXT Sensor Input Ports
Ah, ok. Then I was not very helpful.andrew1019 wrote:Yes Helmut, I am thinking along the lines of port spliters. Running a digital and an analog sensor off one port to save ports. I just started with mindstorms and was wondering if this has been tried using G Blocks to give you more ports with out multiplexing.
-Hayden
-
- Posts: 7
- Joined: 22 Jul 2011, 14:10
Re: NXT Sensor Input Ports
John; Does all that mean I can not read the analog and digital inputs of the same port at the same time with the standerd firmware? Will I/ should I switch to a different programing language to get this to work?Today I added a couple of lines of code to the enhanced NBC/NXC firmware so that it does copy over the ADRaw value even when the sensor type is one of these three values.
I know I have alot to learn.
Thanks Andy
-
- Posts: 7
- Joined: 22 Jul 2011, 14:10
Re: NXT Sensor Input Ports
[quoteAh, ok. Then I was not very helpful.][/quote]
Thats fine you tried.
Thats fine you tried.
Re: NXT Sensor Input Ports
John,
I'm not clear about what you replied to my suggestion.
I did not suggest to read analog when the port was configured as i2c (your post sounded like that).
I suggested to:
configure as analog, then read analog,
then configure as i2c, and read i2c,
then again configure as analog, then read analog,
and so on.
why shouldn't this work?
I'm not clear about what you replied to my suggestion.
I did not suggest to read analog when the port was configured as i2c (your post sounded like that).
I suggested to:
configure as analog, then read analog,
then configure as i2c, and read i2c,
then again configure as analog, then read analog,
and so on.
why shouldn't this work?
Who is online
Users browsing this forum: No registered users and 2 guests