Multiple ADCs?
Jemartin
Posts: 9
Hey,
So, i am looking for some help trying to connect multiple adcs to the prop. I have 3 8ch 10bit adcs (i cant remember the exact chip number right now) connected to the prop. I have the CS, CLK, DIN pins from each adc connected together and then to pins on the prop. Each Dout has its own pin on the prop. I hope theres my crude picture of this at the bottom.
I figured this was the best way to connect them, using the fewest number of pins and allowing for the easiest scaling up and down of adcs. I didnt completely think through how the driver was going to work with the adc, though.
Ive been using brandon nimon's ADC_Input_Driver from the obex with one adc and its been working great. It doesnt, however, work with more than one the way I have the pins tied together.
I feel like it wouldnt be that hard to modify a driver like this to work for multiple adcs, it would just have to alternate which dout pin it reads from. The problem i have is that im not all that proficient with the ASM code yet and dont really understand whats goin on in the driver well enough to be able to modify it.
Im wondering if there is a driver for adcs which is written in all spin that i maybe be able to better modify myself, or if maybe someone could get me set down the correct path for modifying an existing driver to do what i need it to do? Or, perhaps Im completely wrong and it wont work this way at all, or im missing something and theres a different, perhaps simpler, way to use a current adc driver to do what i want?
Thank you
So, i am looking for some help trying to connect multiple adcs to the prop. I have 3 8ch 10bit adcs (i cant remember the exact chip number right now) connected to the prop. I have the CS, CLK, DIN pins from each adc connected together and then to pins on the prop. Each Dout has its own pin on the prop. I hope theres my crude picture of this at the bottom.
I figured this was the best way to connect them, using the fewest number of pins and allowing for the easiest scaling up and down of adcs. I didnt completely think through how the driver was going to work with the adc, though.
Ive been using brandon nimon's ADC_Input_Driver from the obex with one adc and its been working great. It doesnt, however, work with more than one the way I have the pins tied together.
I feel like it wouldnt be that hard to modify a driver like this to work for multiple adcs, it would just have to alternate which dout pin it reads from. The problem i have is that im not all that proficient with the ASM code yet and dont really understand whats goin on in the driver well enough to be able to modify it.
Im wondering if there is a driver for adcs which is written in all spin that i maybe be able to better modify myself, or if maybe someone could get me set down the correct path for modifying an existing driver to do what i need it to do? Or, perhaps Im completely wrong and it wont work this way at all, or im missing something and theres a different, perhaps simpler, way to use a current adc driver to do what i want?
Thank you
Comments
I don't think any driver will work with the wiring you show in the diagram.
In my setup, all 6 data pins (in and out for all three MCP3008s) are tied together to one IO. All three clock pins go to one IO, and each ADC gets a separate IO for the CS pin (so a total of 5 IOs for 3 ADCs)..
The driver can only run one ADC at a time, and when it does, the other two CS pins need to be held high.
So here is my code to start the driver on ADC1:
Modifying the driver would be possible, but difficult, especially since there are only 10 or so free longs in that COG.
well i figured the driver could control the clk and cs pins together, but only read in a value from the adc that you want the value from. So, the getval would have like to inputs, chip and channel. maybe i just dont understand this problem well enough.
i guess dont mind having to change around my pins to make this work and i dont really need any of the 'fancier' features, i just want to be able to get all the values from the adc's and dump them onto a sd card.
Going by your first example, would i have to restart the driver everytime i wanted to read values froma different adc?
I saw that object in the obex, but im running into the same problem of not understanding ASM well enough to be able to modify it.
I guess I just need to focus more on learning ASM.
For that 24-channel object, I'm not sure if the pins can be tied together like I described, but I would think so. The reason they need to be the way I described is that if you have the CS pins tied together, so when you issue a command, you are sending information to all three ADC at the same time, thus you will get information back from them all at the same time. You could design an interesting and very fast driver around that idea, but that is not how any of the drivers are written.
So, if only one CS is held low, and the others are high, the commands only get send to one ADC, and only received from one. Much less confusing.
To modify the 24-channel object, I think all you have to do is change line 283 from "mov bits,#14" to "mov bits,#12".
Just to separate hardware problems from software problems, I would first wire up all ADCs to separate IOs (total 9 IOs). Then try the software, once that is working, rewire it, so you only use 5 IOs.
If you use 3 MCP3208 then this (untested) getADC methode may work with your current circuit:
Andy
This is the exact method I'm going to use on my project because I need the "fancier" stuff.