Easy SDK Upgrade

Update:

I started the upgrade to the newest version of the SDK.

Process:

Upgrading went pretty smoothly.  I had previously downloaded the newest SDK. So I made sure there wasn’t a newer version.  Next I extracted the SDK folder from the downloaded zip file.  I renamed the old folder to indicate it’s version number. I renamed the new SDK folder to Uprogrammer. I copied the code folder (Uprogrammer Firmware) from the old SDK folder into this new one.

Then I compiled (Success), Uploaded (also success after I copied esptools folder), and interacted with the application over serial (again success). Everything seemed to be going great.

Then I opened Eclipse… It didn’t find the project.  So I set my file manager to show hidden files.  I noticed the .metadata folder was not in the new directory. I copied it and still no joy.  I did this for all of the hidden files and it still didn’t work.  I then realized I must not have gotten the spelling of my folder correct.  I checked, the ‘p’ in the folder name needed to be capitalized.

Finally, I checked Git-Cola to see if it worked correctly.  It came up and showed me a bunch of untracked files that were generated by the build I had just done (another success).

This was a very easy upgrade.

The request:

Continue reading

Vpp Control Loop (Firmware V00M)

Plan:

This week I decided to work on the control loop. I decided to add a simple adjustment scheme to the 5 mS system timer event. And then create a way to change the required voltage in increments of 0.1 Volts starting at 10.0

Implementation:

I created a local “static” variable in the events.c file for the target voltage. I then created a function to set this variable target_voltage and another function to get the value of target_voltage.  I then added a simple if statement into the 5ms event that increments the duty cycle of the Sigma Delta if the measured value is too low and decrements it otherwise.  I compiled and tried this, Vpp is ugly.

pic_42_3 Continue reading

ADC analysis (Firmware V00L)

Update:

I forgot to post last week.  If you read this regularly, I am sorry.

Espressif has released a Version 2.0 of it’s SDK.  I am not quite ready to upgrade to that yet, I will wait until after I get my basic functionality tested.  Also, this is a major release, they might have added a few bugs, I can wait till some are fixed.

Voltage Control loop:

I decided to work on the voltage control loop. First step, get a better understanding of the ADC.  I needed to know if the system calls to read the ADC are blocking or nonblocking. An ADC takes time to finish. If it returns the sample from the previous call, I will have to take a second reading to get the correct value.  If it is blocking, I don’t want to call it from within the interrupt service routine (ISR).

Note:  When you call a blocking function, it finishes it’s job before coming back.  Non blocking starts the job and then comes back.

The SDK API is not specific as whether the system_adc_read() is blocking or not.  So I set up a test. Pin 10 of the programming connector connects back to GPIO14.  If I set GPIO14 high before calling system_adc_read() and set it low before calling it again, I can tell how long the call takes. I created a system timer event in events.c and used it to read the adc.  The system timer just calls an os task so it isn’t like an ISR.  I created a function called adc_read.  I initialized a variable, set GPIO14 high, call system_adc_read() and set GPIO14 low. I then set up the function to enable the timer task, I called it init_adc_timer().  I called this from user_init().  The code built. I uploaded it. I hooked up my scope to Pin 10 of the target header.

I got nothing, I didn’t hook up Vtarget.  I decided it was easier to probe GPIO14 directly on the ESP-12F. The pin was always high.  I checked the pin configuration in user_main.c. Nothing wrong there. I found a copy/paste error in events.c  I had copied the line to change GPIO13 to low and changed it to GPIO14 to set it high but didn’t change the one to set it low.  I fixed this and tried again.  I got the pulses I was looking for on the Oscilloscope.  The high pulse width measured 96.2 μS.  This is much longer than I would put into an ISR.  If i polled this read regularly, It would cause a significant loss in performance.

The Next Step:

I decided to see if I could access the ADC directly through hardware registers.  I couldn’t find any clear documentation on the ADC registers.  In the API, there is also a function call system_adc_read_fast().  This one requires wifi to be turned off when called.  I decided to try it turning Wifi off and back on after around each read.  I modified the code to try this change. Now the pulse width is 21.8 μS. Unfortunately, the wifi disconnects when I disable it. This is a problem.  I tried leaving the wifi enabled and it works. 21.8 μS is longer than I would want in an ISR so I will call it from the os_timer function and use it to make adjustments.  If I call this every 5 mS, it will tie up the processor for about 1/2 of 1% of the time.  This doesn’t seem like a lot, but I want to get as much performance as I can when I am programming a target.  And this control loop will have to be running while programming a target.

Conclusion:

The results of my testing are not as good as I had hoped.  Maybe Espressif will come out with a non-blocking way to use the ADC in the future. Ideally, I would call a function to start the conversion, and the system would call back to my function with the result. As a final step I display the menu with the adc reading once every 200 cycles (1 second).  I have uploaded these changes to github click the link in the right column to go check it out.

Do you have any experience with the ESP8266 adc?  Have you found a work around for the blocking call?

New Build

Update:

The level shifter came in this week.

Populating the board:

I installed parts out of my kit in the order that I grabbed them, until I had enough to do the basic test.  The board powered up and the blue LED on the ESP-12F blinked once.  Unfortunately the board wouldn’t program.

I started probing with my Oscilloscope.  The serial data lines looked normal when I tried to program the board. Then I looked at Reset and GPIO0 lines and found that GPIO0 was oscillating at 24 MHz. The Reset line was working as I expected it to.  I used a 1 MOhm resister as a pull down on GPIO15. I chose 1 MOhm to reduce the amount of current when A_Sel is High.  I knew this could cause me trouble, GPIO15 is used to put the chip into SD card mode. That may be too much resistance.  I changed that resistor to 10 KOhms to see if it made a difference. It did!

I uploaded the defaults, then my code. My simple serial menu came up in the terminal. With it working, I went on to populate the rest of the board.  I came up short 2 components, the pin header I use for the lithium cell and Q2.  I grabbed both of those from the last build and completed populating the board. I reconnected it to my computer, re-connected the serial terminal and the serial menu is still working.

SPI RAM Testing:

Continue reading

New PCBs

Update:

I received the PCBs from PCBWay this week.  I have not received the level shifter yet.

The PCBs

The new PCBs look good.  Unfortunately the silkscreen part of my logo is not as crisp as I had hoped.  The arrows still have too small of a gap and the silkscreen bridged together at one point.  I still need to modify the logo.

newlogo

Side Projects:

Continue reading

Vpp regulation (Firmware V00K)

Update

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.

Testing

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.

Failure

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).

Diagnostics

Continue reading

Post 100

Statistics

I have been writing this blog for almost two years now.  With only about two hundred views per month. Of the two hundred per month, only about twenty five are returning visitors. I have received six real comments in this time.(and tons of spam comments)

I was hoping to get more comments to help me know what is interesting to the people that do make it to my site.  Also, I am not a writer, I am unsure if I am giving too much information or not enough.  These statistics are a little disappointing, but I will continue to write and hopefully improve my skills.

Status Update

The boards are fabricated and have been shipped from PCBWay.  I am looking forward to testing the changes  I have made to the layout.  While doing some testing, I hooked up the lithium cell backwards and fried the charger chip. I replaced it and the board is back up and running.  I have ordered the new level translator chip so I will be able to test it when the new boards come in.

Looking Forward

As I build it this next time, I will be looking for ways to make it less expensive and more reliable.  One thing I would like to improve is how easy the board is to solder, the lithium cell charger is very difficult to solder.

In the coming weeks, I plan on re-testing the hardware, Improving the software, and doing some functional testing.  In essence, I am hoping to move from prototype stage to alpha stage.  The software should start to look like the final product and the electronics shouldn’t need to change much if at all.

Goals:

Continue reading

Layout check … continued

With the new check plots I made last week, I checked the layout net by net like I did back in Sept 5, 2015. I am still uncertain about the pinout of the ESP-12F modules. To test it, I removed the ESP-12E installed on the board I am currently using, and replaced it with a new ESP-12F.  I had to be careful that the jumper wires all got back to where they were before removing the module.

The new module programmed first try but didn’t boot correctly.  I had forgot to upload default values, the flash comes programmed for a different memory layout.  Once I installed the default settings, it booted up correctly.  I had removed the test for HSPI/SPI RAM, so I went back into the code and re-enabled the Hello World ram test.

I went into serialInit() and changed the line DISPLAY_MENU(); to DISPLAY_MENU_W_SPI(); Re-compiled and tested.  Unfortunately the result was not “Hello World”. When I cleaned up the code, I made the write to SPI RAM easier, but I need to initialize the hspi.  I started connecting my mixed signal oscope to analyze what was happening on the SPI bus.  And… I found a loose jumper wire.  The one that connects the chip select between the ESP-12F and the SPI RAM. Once this was connected, the extra stuff I had put into the software became unnecessary.  I deleted the extra code and it works just fine.  The firmware is back to where it was before I started testing. There are no changes to upload.

This means that the circuit is tested and the current layout is ready to send to fabrication.  I zipped up the gerber files. Then checked pricing with PCBway, DFRobot, and Seeed Studio.  With shipping PCBway came in a little less at US $19.  With PCBway, I have to wait for a design review before they will give me a final price and allow me to pay for it. Usually this is pretty quick but depends on the day it is submitted.

Have you bought boards from Chinese manufacturers? How quickly did you get them?

Layout Verification (Hardware V00J)

The changes I made to the layout last week were pretty extensive especially concerning the level shifter IC. I don’t want to do layout verification, but It needs to be done. Like when i did the check plots before, I printed out the schematic and each layer. Then I physically traced the circuits both on the schematic and the layer plots.  I use colored pens to help differentiate each net.  Before printing, I removed the note from the schematic about testing the lithium cell charger.

I plotted the top copper, bottom copper, top silk, and Edge cuts layers to PDF file and imported them into gimp. I then removed the white background from each layer, and then put a new layer at the bottom layer filled with white. I left the board outline unchanged.  Then I changed the top silkscreen layer to yellow, and faded the copper layers to about 25% black.  This allows me to see the color of the pens while I am tracing the circuits.

I found that I hadn’t updated the RTS and DTR lines used in programming. They were swapped and I changed them on the board when I received the new PCBs on the last spin.  So I had to go back into the schematic and change them.  I vertically swapped the cross linked transistors and resistors R19,20, Q7,8 on the schematic so that effectively RTS and DTR are swapped. I re-ran the netlist, imported it into PCBNew and proceeded to make the adjustments to the layout.

rtsdtrswap

As I was looking at the layout, I was able to see a cleaner layout of these parts. So I made the adjustments.  Also, I remembered I wanted to modify my logo on the board.  The arrows aren’t visible on the silkscreen, so I went back into Gimp and edited them to make the gap bigger.

dtrrtsswappluslogo

Unfortunately PCBnew renders the pad on top of the silkscreen so you can’t see the new arrows.  I re-printed the schematic and layouts just like I did this week and I will check the layout again before I order another spin.  I am glad I caught this mistake now and not after the next spin of the board.  As before, the intellectual property for the Uprogrammer is still licensed with the MIT license. My logo is my trademark and I reserve all rights.

Because the schematic and layout have both changed, I have uploaded a new version to Github.

Do you like to “clean up” your layouts when checking them?  Are you doing any layouts at this time?

Update layout Hardware V00I

Finally time to update the layout.  The charging circuit works well and I changed the level shifter on the schematic last week. So this week, I updated the layout.

I started by generating a new netlist. Next, I ran CvPCB to verify all the parts had footprints associated with them. They all do. Next I ran PCBnew and imported the netlist; making sure the exchange footprint settins was set to change.  I got an error:

Error: Component 'U3' pad '~' not found in footprint 'Housings_SSOP:TSSOP-20_4.4x6.5mm_Pitch0.65mm'

I had to figure out what that means before moving on.  It suggest one of the pins was named wrong either in the schematic symbol or the footprint library. I checked the schematic symbol first. I noticed the GND pin didn’t have a pin number assigned to it. Easy fix, added it and updated the library. I set the GND pin number to 11, saved it to the library, made sure it was in the schematic correctly, and re-generated the netlist.  I had to delete it and re-place it into the schematic to correct the schematic.  This meant that CvPCB no longer knew the footprint to use, so I updated it and re-generated the netlist again. No more errors in PCBnew import of the netlist.

I started by ripping up the unconnected traces. Then I started placing footprints.  I hid the bottom layer to make it easier to see what I was working around on the top layer.  Once I had the parts placed, I started routing traces.  I had to adjust component placement a few times to get everything to fit.  As I got to a point that I couldn’t do all the traces on the top side of the board, I un-hid the bottom layer.  While I was working with both sides, I had to re-fill the zones several times to correct for the areas I added new traces on the bottom side.

I finally got to 0 unconnected nets. I did a quick look to make sure all the references were readable and not under other parts.

layoutv00i

I plotted out the Gerber files and did a quick check to see if it looked OK and got ready to order.  When I look at Gerbers, I am looking for broken traces and unintentionally connected traces.  I used Gerbview to do this check. As I went into Gerbview and tried to load the files, the were double of all the files.  It looks like the developers of KiCad decided to change the naming conventions  for output to gerber.  I went in and deleted all the files in that folder and re-ran the plots.  While looking at the gerber files, C10 and U3 references were covered up.  I went in and fixed them and re-plotted.  While I was at it, I discovered U10 wasn’t anywhere near it’s footprint.

I created a zip file with the plot files ready to upload to a fabrication house. I have uploaded the files to the github repository, click the hardware link in the right column to go get it.

Are you using Kicad?  What tools are you using to design in?  Do you have trouble finding datasheets for Chinese parts?