#172982 - Aurelio - Sun Mar 14, 2010 11:43 am
Hi!
I need to read an external analog input on my DS. I was thinking of using slot2 for doing this, but i don't really know how to do this.
I just need to read a couple of potentiometers.
Can you help me?
Thank you,
Aurelio
#173003 - sverx - Mon Mar 15, 2010 10:57 am
I believe there are no analog inputs on slot-2 so maybe you could check that topic here about NDS & Arduino ...
#173010 - Aurelio - Mon Mar 15, 2010 2:15 pm
I want to do something like the motion sensor(but i just want to read a couple of potentiometers, not an accelerometer).
I read the code of the part of libnds about the ndsmotion(slot2 version) and I saw that it read some values from the SRAM, how can I do that?
Thank you
#173011 - kusma - Mon Mar 15, 2010 2:23 pm
Aurelio wrote: |
I want to do something like the motion sensor(but i just want to read a couple of potentiometers, not an accelerometer).
I read the code of the part of libnds about the ndsmotion(slot2 version) and I saw that it read some values from the SRAM, how can I do that?
Thank you |
Are you planning to make your own cartridge? If so, I guess you could communicate over the cartridge bus. But the signal will be digital, so you'll need an AD converter on the cartridge.
#173012 - Aurelio - Mon Mar 15, 2010 2:57 pm
kusma wrote: |
Aurelio wrote: | I want to do something like the motion sensor(but i just want to read a couple of potentiometers, not an accelerometer).
I read the code of the part of libnds about the ndsmotion(slot2 version) and I saw that it read some values from the SRAM, how can I do that?
Thank you |
Are you planning to make your own cartridge? If so, I guess you could communicate over the cartridge bus. But the signal will be digital, so you'll need an AD converter on the cartridge. |
Yes, I'm planning to make my own catridge. Can you help me to do the schematic of the catridge? Thanks
#173013 - headspin - Mon Mar 15, 2010 3:55 pm
What ever happened to Natrium42's DSSerial card? Anyway he does have this in his store.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game
#173014 - Aurelio - Mon Mar 15, 2010 4:05 pm
DSerial is slot1, i need a slot2 card.
That card from electrobee is too expensive.
#173084 - headspin - Sat Mar 20, 2010 8:09 am
Perhaps something like this will help you make one?
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game
#173087 - kusma - Sat Mar 20, 2010 2:25 pm
Aurelio wrote: |
kusma wrote: | Are you planning to make your own cartridge? If so, I guess you could communicate over the cartridge bus. But the signal will be digital, so you'll need an AD converter on the cartridge. |
Yes, I'm planning to make my own catridge. Can you help me to do the schematic of the catridge? Thanks |
I'm sorry, but I can't. I'm not a hardware engineer, and my only knowledge of these things come from friends and former co-workers who are ;)
#173295 - Aurelio - Tue Mar 30, 2010 2:38 pm
Anyone can help me?
#173300 - headspin - Tue Mar 30, 2010 8:09 pm
Aurelio wrote: |
Anyone can help me? |
You don't want to buy the cart I suggested because it's too expensive. So you want to make one. I posted a link to a website that shows you how to make an interface for a camera with open source software. That could be modified to suit your needs.
If you can't make one, buy that cart. If you can't afford it, I guess your out of luck!
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game
#173301 - Aurelio - Tue Mar 30, 2010 8:15 pm
It only handle buttons, I need to read values from potentiometers
#173304 - headspin - Tue Mar 30, 2010 9:53 pm
If you don't have any skills in electronics how would you make it in the first place? What is a button other than a single bit? If you combine multiple bits and you have enough of them you can send/receive an analog value. ie. 8 bits gives you 0-255 digital signal.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game
#173318 - sverx - Wed Mar 31, 2010 9:14 am
I suggest you again to check Arduino Duemilanove, it has 6 analog inputs and you can use it for many other things beside what you want to do with the DS.
#177896 - WriteASM - Sun Apr 21, 2013 3:57 pm
It's been about three years since the last post here, obviously, but it is possible to get analog readings with only digital I/Os, and a couple of passive external components. Parts you can easily remove from obsolete/nonworking devices.
The general theory uses a R-C circuit, where the controller discharges the capacitor, and then times how long it takes for the capacitor (C) to recharge through the resistor (R). Note that the values will be upside-down, where lower voltage = higher output count; the result (or the circuit) can be flipped.
The simplest method requires one bidirectional I/O pin (I.E. link port), one capacitor, and one resistor. Connect the capacitor from the I/O pin to ground (0v, VSS, whatever you call it), and the resistor from the I/O pin to the analog source.
Code needs to do the following:
??Step 1: Set the I/O pin to output (0): This discharges the capacitor; a small delay is required here.
??Step 2: Start a timer, and set the I/O pin to an input
??Step 3: When the I/O pin reads (1), stop the timer, read the value.
A slightly more complex method can probably be used in a cartridge if there is an input-only pin for "sense", and one I/O or "static" output-only pin for discharge/reset. Connect the resistor and capacitor as with the above example to the input-only "sense" pin, but this time add a small diode between the two pins, ring side to the "reset pin". The read process becomes as follows:
??Step 1: Set the "reset" pin to output (0). The capacitor is discharged through the diode and the "reset" pin.
??Step 2: Set the "reset" pin to output (1), releasing the capacitor. Start a timer.
??Step 3: (same as first method). Note that the diode will not discharge the capacitor as far.
None of the values are critical--if you want a fast "read", use a smaller capacitor (0.01uF, etc.) If you want more precision, use a larger capacitor (I.E. 1uF.) The resistor, obviously also is important. Off the top of my head, I'd suggest 10K, but that's just a start.
The reset signal can be shared between multiple channels, but the discharge time will need to be correspondingly increased...especially if one channel affects the others, or if there are residual values. The signal can also be buffered with a transistor.
Note that the lower the output value, the faster the routine will return, and vice-versa. And, of course, the result will not be linear without a constant-current source to the capacitor. Obviously, this isn't for everyone.
Just so you know, I've had relatively good success with this method. Of course, a real A/D is a lot easier to work with, besides being perfectly linear and rock-solid! But when you don't have one...:-)
_________________
"Finally, brethren, whatever is true, whatever is honorable, whatever is right, whatever is pure, whatever is lovely, whatever is of good repute, if there is any excellence and if anything worthy of praise, dwell on these things." (Philippians 4:8)
#177897 - WriteASM - Sun Apr 21, 2013 3:59 pm
It's been about three years since the last post here, obviously, but it is possible to get analog readings with only digital I/Os, and a couple of passive external components. Parts you can easily remove from obsolete/nonworking devices.
The general theory uses a R-C circuit, where the controller discharges the capacitor, and then times how long it takes for the capacitor (C) to recharge through the resistor (R). Note that the values will be upside-down, where lower voltage = higher output count; the result (or the circuit) can be flipped.
The simplest method requires one bidirectional I/O pin (I.E. link port), one capacitor, and one resistor. Connect the capacitor from the I/O pin to ground (0v, VSS, whatever you call it), and the resistor from the I/O pin to the analog source.
Code needs to do the following:
--Step 1: Set the I/O pin to output (0): This discharges the capacitor; a small delay is required here.
--Step 2: Start a timer, and set the I/O pin to an input
--Step 3: When the I/O pin reads (1), stop the timer, read the value.
A slightly more complex method can probably be used in a cartridge if there is an input-only pin for "sense", and one I/O or "static" output-only pin for discharge/reset. Connect the resistor and capacitor as with the above example to the input-only "sense" pin, but this time add a small diode between the two pins, ring side to the "reset pin". The read process becomes as follows:
--Step 1: Set the "reset" pin to output (0). The capacitor is discharged through the diode and the "reset" pin.
--Step 2: Set the "reset" pin to output (1), releasing the capacitor. Start a timer.
--Step 3: (same as first method). Note that the diode will not discharge the capacitor as far.
None of the values are critical--if you want a fast "read", use a smaller capacitor (0.01uF, etc.) If you want more precision, use a larger capacitor (I.E. 1uF.) The resistor, obviously also is important. Off the top of my head, I'd suggest 10K, but that's just a start.
The reset signal can be shared between multiple channels, but the discharge time will need to be correspondingly increased...especially if one channel affects the others, or if there are residual values. The signal can also be buffered with a transistor.
Note that the lower the output value, the faster the routine will return, and vice-versa. And, of course, the result will not be linear without a constant-current source to the capacitor. Obviously, this isn't for everyone.
Just so you know, I've had relatively good success with this method. Of course, a real A/D is a lot easier to work with, besides being perfectly linear and rock-solid! But when you don't have one...:-)
_________________
"Finally, brethren, whatever is true, whatever is honorable, whatever is right, whatever is pure, whatever is lovely, whatever is of good repute, if there is any excellence and if anything worthy of praise, dwell on these things." (Philippians 4:8)
#177900 - sverx - Mon Apr 22, 2013 10:17 am