Code only runs when USB serial connected

Questions and discussion about The WiPy board.
You can buy one at the store.
Target audience: Users with a WiPy.
smssms
Posts: 10
Joined: Tue Feb 14, 2017 8:37 am

Code only runs when USB serial connected

Postby smssms » Mon Mar 20, 2017 8:14 pm

Has anyone else experienced this:

I have some code which will run fine in the REPL as snippets, it will run fine as main.py (with USB serial connected), but when I try to run it without the USB plugged in, it just stops part way through. As I don't have the USB connected I can't see error messages or exactly where it fails.

User avatar
Roberthh
Posts: 534
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Code only runs when USB serial connected

Postby Roberthh » Tue Mar 21, 2017 6:34 am

Will it run when connected though telnet? Or do you see the error message then?

smssms
Posts: 10
Joined: Tue Feb 14, 2017 8:37 am

Re: Code only runs when USB serial connected

Postby smssms » Tue Mar 21, 2017 10:46 am

It will not run with a Telnet connection either (and there are no error messages when it fails on Telnet).

I've had a stab at try: except: to write exceptions to the SD card, but nothing seems to go there.

I'm starting to thing it is some sort of power supply issue i.e. it is only working with USB power available. But it is strange that it fails part way through the code, it can run boot.py and the first 1/3 of main.py.
Last edited by smssms on Tue Mar 21, 2017 11:26 am, edited 1 time in total.

User avatar
Roberthh
Posts: 534
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Code only runs when USB serial connected

Postby Roberthh » Tue Mar 21, 2017 11:04 am

How do you power the device in the absence of USB?

smssms
Posts: 10
Joined: Tue Feb 14, 2017 8:37 am

Re: Code only runs when USB serial connected

Postby smssms » Tue Mar 21, 2017 11:31 am

XP JCJ1012S05 1.5A 5V output DC/DC converter into Vin/Gnd Plus 10uF capacitor for smoothing as it also has to run a stepper motor. The max. draw is only 800mA, so well within the supply's limits. The stepper motor is running in the first 1/3 of main.py too with no problems. But without USB, it just seems to hit a point where it freezes with no error messages (that I can capture).

http://uk.farnell.com/xp-power/jcj1012s05/converter-dc-dc-10w-5v/dp/1637871

User avatar
Roberthh
Posts: 534
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Code only runs when USB serial connected

Postby Roberthh » Tue Mar 21, 2017 11:58 am

The supply looks fine. Assuming that you power the WiPy 1(?) on the expansion board and lookg at the schematics, it seems, that the USB/Serial chip is not powered when you suply though Vin. That may cause Tx/Rx/CTS and RTS to be pulled low. I do not know what that causes to the device. But just for test, you could remove the jumpers for TX, RX, CTS and RTS.

smssms
Posts: 10
Joined: Tue Feb 14, 2017 8:37 am

Re: Code only runs when USB serial connected

Postby smssms » Tue Mar 21, 2017 12:12 pm

It is the latest WiPy and on an Expansion Board.

Tried removing the jumpers as described - same problem :(

Online
devnull
Posts: 54
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall

Re: Code only runs when USB serial connected

Postby devnull » Tue Mar 21, 2017 12:20 pm

I faced a similar problem and the cause is a lack of pullup on either the TX / RX or both (don't recall which).

When you connect a USB > Serial, the TX/RX Lines are pulled high, but when disconnected they are floating and the device will not start as it is waiting for the high signal.
Last edited by devnull on Tue Mar 21, 2017 11:23 pm, edited 1 time in total.

smssms
Posts: 10
Joined: Tue Feb 14, 2017 8:37 am

Re: Code only runs when USB serial connected

Postby smssms » Tue Mar 21, 2017 2:07 pm

SOLVED

Despite the stepper motor working fine upto the point of failure, it looks like it was a power supply issue.

When I drive the stepper motor from a separate supply it all seems to work ok with or without USB connected.


Return to “The WiPy”

Who is online

Users browsing this forum: No registered users and 1 guest