Go Down

Topic: Successive Approximation ADC Code (Read 356 times) previous topic - next topic

Tashrafkhan

Hello All
Can you guys help me with a project I'm working on. I'm trying to built a Analog to Digital converter working on Successive Approximation algorithm. How should I proceed with the code?

6v6gt

Is you intention to build the hardware or are you simply going to convert the flowchart into C++ ?
To convert to C++ you need an 8 element array to represent the register, read some voltages and maintain some counters. You can't really test it, though. All you can do is check it compiles Ok.

Tashrafkhan

my intention is to convert the flow chart into C++, I have the hardware to test on.

PaulRB


Tashrafkhan

I've already provided the schematic and the flow chart along my post

6v6gt

OK. So I guess that is an "academic" exercise. The flow chart describes the logic you have to implement in the box labeled "Control Logic and output register".

It looks like you have 3 inputs (GPIO pins): inputs Clock, Start Conversion and Comparator.
You have 1 simple digital output: EOC
You have to understand how you deliver data to the DAC. In the worst case, this requires 8 output pins.
You also have to know how you are to deliver the final output. Maybe writing to the serial monitor is good enough or some other serial method. You'll have a problem with a small microprocessor if it also has to be a parallel output because you'll soon run out of GPIO pins.



I've already provided the schematic and the flow chart along my post
What does the DAC look like in the hardware ?

Paul__B

You'll have a problem with a small microprocessor if it also has to be a parallel output because you'll soon run out of GPIO pins.
Actually, that is fairly easy.  That parallel output is what is fed to the DAC.  When it is finalised, you merely strobe it to whatever successive device you wish.

6v6gt

Actually, that is fairly easy.  That parallel output is what is fed to the DAC.  When it is finalised, you merely strobe it to whatever successive device you wish.
That is possible, but these appear to be drawn in the block diagram as separate 8 bit bus. Maybe also that the "Arduino" the OP is using to implement the control logic also includes an external 8 bit shift register.

I found the exercise quite interesting because I have never studied a successive approximation ADC before and now, from this thread, I have understood how it works. We didn't do interesting stuff like that when I was at school.

david_2018

Do you have an actual schematic showing how the hardware is wired, the "schematic" given in the pdf document is more of a block diagram, and doesn't give anywhere near enough information for anyone to give you specific advice. The flowchart gives the basic logic for the code, have you made any attempt to write the code, and if so can you post it?

The only confusing part I see in the logic is that the MSB is being referred to as D1, and the counter k starts at 1, most programmers are going to think of MSB as D7 and LSB as D0, and start loop counters at 0.

Paul__B

most programmers are going to think of MSB as D7 and LSB as D0, and start loop counters at 0.
That would of course, depend on whether they are Lilliputian or Blefuscutian.

Go Up