Vpp regulation (Firmware V00K)


Neither the PCBs or components have arrived yet.

The decision

This week I decided to work on the Vpp feedback loop. I am interested to see how well the system can regulate the boosted voltage operating on an interrupt driven control loop.


I needed to see if I could get reliable numbers back from the ADC while generating a given voltage.  First step then was to make it so I could change the state of the analog switch from the serial console.  I used the keys ‘<‘ and ‘>’ to select which input I would be connected to the ADC. I wasn’t sure which signal would be connected to the ADC, So I made sure I could select each one individually. Typing < into the console sets GPIO15 to low and typing > sets GPIO15 high. While setting this up, I discovered that GPIO2 wasn’t configured correctly like I had thought.  I fixed this and added the little bit of code to give me control and tried it.  It built and uploaded without a hitch.


The code was running, ready to test. I hooked up my oscilloscope to watch the output of the Vpp pin to compare to the analog readings.  When first hooked up, the scope was reading 4.8V and the ADC gave me a result of 15. (ADC should give a result of approximately 230.) I hit the > to see and I got a result of 24.  (off by a factor of 10).  I decided to see if that would hold. I played with the Sigma delta till I got an output around 10 volts. I landed at 10.8V.  At this voltage, the ADC result was 24(no change).  This was disappointing. I hit the < key and read out the ADC with result of 20. Not what I was looking for. (expected something either twice the original value of 15 or 512)  The results are not what I had expected(fail).


First step I probed the inputs and outputs of the analog switch.  Pin 3 should be at the same level as pin4. Pin 3 was at 512mV (Where I expected it). Pin 4 unfortunately measured at 30mV. No connection. I hit the > key to see if it made any difference. Pin6 (select) was not changing when I hit the < and > keys.  I needed to look at an old schematic, I had changed GPIO15 from use on the HSPI.  I searched back through the posts and found that I used to have GPIO0 tied to the select line.  I cut the trace connecting them, and added a jumper to GPIO15. I re-hooked up my scope and with a voltage of 5.40 The ADC was reading 246 (Represents 5.0V). Then I fiddled the Sigma-Delta again and with the scope measuring 10.8V, the ADC Reading was 522 (Represents 10.7 V)  The first calculations were off a little and I went back and corrected them for the post.

The Math

Vps = 1V when Vpp = 21V

ADC divides the 1 volt maximum reading into 1024 discreet steps. So 1.0V(21V Vpp) results with a value of 1023 and 0.0V (Vpp turned off) should read as 0 from the ADC. Since I want to generate a specific voltage, I need a to calculate the voltage from the ADC reading.

ADC = 1023*(Vpp/21)

ADC/1023 = Vpp/21

Vpp = (21*ADC)/1023

I put this last equation into the code where I am displaying the value and it is very close to the readings I get off of my oscilloscope.


I didn’t get the control loop even started this week. I know now, I can get reliable results from the ADC and I tested a part of the circuit I forgot to test before the new layout. And… It works!  Maybe next week I will get the software control loop started. For now, I know that a low on GPIO15 will select Vpp to be measured by the ADC and a high will select Vt to be measured by the ADC.  I have uploaded the new version of code to github.  Click the Firmware on GitHub link to go look at the code and download it.

Do you have any experience with ADCs? How about analog switches?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.