I am planning to use a solar charger and Li battery from Adafruit http://www.adafruit.com/product/390 to run the pyboard. I would like to be able to debug my code while it is running on solar charger. the Is there a way to use USB and REPL while still powering the pyboard from the solar charger? As per my understanding, once the USB is plugged-in the pyboard powers itself from the USB exclusively.
If the above method is not possible other suggestions would be appreciated.
solar battery charger to pyboard Question
Re: solar battery charger to pyboard Question
I take it that your goal is to have your pyboard running continuously, powered by a solar-charged battery, and occasionally connect to USB to debug, download data or update the code you are running? This should be possible, but there are a few things to consider.
When the pyboard is connected to USB, the power from the USB port goes through diode D1 to the onboard bus labeled VIN; this is to prevent current from being driven back to the Host USB port when there is another power supply connected to VIN (as you are trying to do.)
Note that the Adafruit board is prominently labeled "No Diode Protection"; you may want to add this diode protection. The result will be something called a 'diode OR'; the pyboard will draw power from either the USB port or the battery charger, whichever is providing slightly more voltage, and current won't be driven back into either supply.
The other issue is one that I haven't investigated: whether the USB stack on the pyboard deals gracefully with being disconnected and reconnected without rebooting. If the answer is no, then another option is to pass the REPL though one of the UART's instead of the onboard USB port and use an external USB/Serial converter cable (Adafruit sells these as well, which I am currently using for that purpose: http://www.adafruit.com/products/954) If you choose this method, you won't need to worry about the USB power issue; just be sure _not_ to connect the red 5V wire from the USB-Serial cable to VIN on the pyboard.
To get the REPL on UART4 (X1 and X2 on the pyboard) add the following line to your 'boot.py': 'pyb.repl_uart(4)'
-Bryan
When the pyboard is connected to USB, the power from the USB port goes through diode D1 to the onboard bus labeled VIN; this is to prevent current from being driven back to the Host USB port when there is another power supply connected to VIN (as you are trying to do.)
Note that the Adafruit board is prominently labeled "No Diode Protection"; you may want to add this diode protection. The result will be something called a 'diode OR'; the pyboard will draw power from either the USB port or the battery charger, whichever is providing slightly more voltage, and current won't be driven back into either supply.
The other issue is one that I haven't investigated: whether the USB stack on the pyboard deals gracefully with being disconnected and reconnected without rebooting. If the answer is no, then another option is to pass the REPL though one of the UART's instead of the onboard USB port and use an external USB/Serial converter cable (Adafruit sells these as well, which I am currently using for that purpose: http://www.adafruit.com/products/954) If you choose this method, you won't need to worry about the USB power issue; just be sure _not_ to connect the red 5V wire from the USB-Serial cable to VIN on the pyboard.
To get the REPL on UART4 (X1 and X2 on the pyboard) add the following line to your 'boot.py': 'pyb.repl_uart(4)'
-Bryan
Re: solar battery charger to pyboard Question
The pyboard uses the prescense of the USB power to detect that a USB cable is plugged in.
As Bryan suggests, you can still connect via a HW UART. There will still be some leakage current through the Rx line unless you isolate it using some type of optical coupler.
As Bryan suggests, you can still connect via a HW UART. There will still be some leakage current through the Rx line unless you isolate it using some type of optical coupler.
Re: solar battery charger to pyboard Question
Thanks for the info guys. I ordered the suggested Adafruit serial converter cable. Just to make sure I don't connect the cable up wrong, my understanding is: X1->TX (green wire), X2 -> RX (white wire), pyboard's GND to (black wire) and no connection for the red wire.
Is it ok to use the boot.py setting of:
pyb.usb_mode('CDC+MSC') when there is no USB cable connected? I've tried using the mode: pyb.usb_mode('CDC') but my SD logging application fails to write to the SD card in this case.
Is it ok to use the boot.py setting of:
pyb.usb_mode('CDC+MSC') when there is no USB cable connected? I've tried using the mode: pyb.usb_mode('CDC') but my SD logging application fails to write to the SD card in this case.
Re: solar battery charger to pyboard Question
You should be able to use any pyb.usb_mode and it shouldn't have any affect on sd card writing. If somehow it does, that would be a pretty serious bug. If you can reproduce this, I'd be very interested in investigating further and seeing a test case for this. Calling pyb.usb_mode with an invalid mode will raise an exception
From the pyboard's perspective Tx is an output and Rx is an input. The serial adapter treats these the same way. So you need to connect Tx on one to Rx on the other and vice-versa (so you're connecting an input to an output).
So the Tx/Rx wiring will be the reverse of what you suggested.
From the pyboard's point of view X1 is UART4 Tx so that would connect to Rx (white) on the serial adapter.
X2 is UART4 Rx and this would connect to Tx (green) on the serial adapter.
And as you mentioned, you need to connect the ground up between the pyboard and the serial adapter.
You can leave the power wire from the serial adapter unconnected. You'd only connect that up if you were trying to power the pyboard from the serial adapter. If you decided to do that the red wire would connect to VIN.
From the pyboard's perspective Tx is an output and Rx is an input. The serial adapter treats these the same way. So you need to connect Tx on one to Rx on the other and vice-versa (so you're connecting an input to an output).
So the Tx/Rx wiring will be the reverse of what you suggested.
From the pyboard's point of view X1 is UART4 Tx so that would connect to Rx (white) on the serial adapter.
X2 is UART4 Rx and this would connect to Tx (green) on the serial adapter.
And as you mentioned, you need to connect the ground up between the pyboard and the serial adapter.
You can leave the power wire from the serial adapter unconnected. You'd only connect that up if you were trying to power the pyboard from the serial adapter. If you decided to do that the red wire would connect to VIN.
Re: solar battery charger to pyboard Question
I've seen this behavior only when my USB cable is connected. Maybe it is related to the windows/USB driver issue which Robert verified in the post below.You should be able to use any pyb.usb_mode and it shouldn't have any affect on sd card writing.
Hello all. At least I can confirm that behavior for both Windows 7 and Windows 10. When USB is set to CDC only, the device behaves differently. using the modified INF file, Windows detects a serial interface, but both Putty and TeraTerm refuse access to that port.
I had an interesting behavior with Android USB terminal emulators, which I tried today. Most of them did not work, even with plain Prolific and FTDI device. But with the one app that worked, I could get responses from PyBoard in CDC only mode, if a) I told the app it was an Prolific device, and b) DTR and RTS were switched on.
Robert
Re: solar battery charger to pyboard Question
This just showed up in my inbox today and since it implements a simple isolator I thought it was relevant:
http://www.edn.com/design/systems-desig ... es-for--20
http://www.edn.com/design/systems-desig ... es-for--20