BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:41 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Serin won't run after shut down:
PostPosted: Thu Nov 03, 2011 7:10 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Well it was worth the try...

If it were me, some of the things I would try include:

1) Adding extra debug code, that either printed data to S_OUT or to LEDS or... that showed if and what data was received on P12. So you can see if the data is garbled. I would also hook up my logic analyzer, but that is cheating :D.

2) Try different IO pins.

3) Play around with some init code. Maybe the Nano is now not properly putting P12 into an input pin. So try adding:
input p12
Just before the serin command.

4) Like 3, but maybe modify or check with some of the PIC registers associated with this IO pin. I have not done anything with PICs before so I am only guessing, but I think there are at least 3 registers (PORTA, TRISA, ANSEL) associated with this IO pin. Maybe the appropriate bit is not set in ANSEL to make it a normal IO pin...

5) Verify wiring. That is Do I have both a signal wire coming from the other board to the NANO, but do I also have a ground wire.

Good Luck
Kurt


Top
 Profile  
 
 Post subject: Re: Serin won't run after shut down:
PostPosted: Thu Nov 03, 2011 10:34 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
So how are you getting it to work the first time? Right after programming the chip it works? What about after a reset(not a power down)? Also is that the whole program or is that a trimmed down version?

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Serin won't run after shut down:
PostPosted: Thu Nov 03, 2011 5:29 pm 
Offline
Citizen

Joined: Fri Oct 28, 2011 4:18 pm
Posts: 7
Acidtech wrote:
So how are you getting it to work the first time? Right after programming the chip it works? What about after a reset(not a power down)? Also is that the whole program or is that a trimmed down version?


Yes it works after programming the chip. I power up, program the chip, unhook the serial programing cable and I can happily turn lights on from across the room sending 1's and 2's from my laptop connected to the radio. I can send the command 50 times, works fine, I can leave it sit and run for hours, works fine. I can turn off the radios, then turn them back on, it works fine. I just can't power down the chip, if I do, it hangs after the LED flashes on.

The board this is running on does not have a reset switch. RES pin is pulled high via a 10K resistor. But obviously it is resetting at power up since it always runs the first part of the program which turns on the LED. And that is the entire program, like I said it's not doing much.

Kurt, I have tried other pins, the Nano SER pin itself, different boards (of the same design), all have the same problem.

I had hoped someone would just say you forgot this, or do this you idiot, and it would be fixed. This is not something I do as a hobby, it's a means to an end. So I don't spend a lot of time working with uC's other than to do a specific job now and then. So something that may seem very basic may well be over my head. Again, thanks for the ideas.

Scott


Top
 Profile  
 
 Post subject: Re: Serin won't run after shut down:
PostPosted: Fri Nov 04, 2011 9:18 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Well I suggest you wire up that reset pin so you can reset it. Then we can see if it is purely a power on issue and you can get out of it with reset or it, it is a more general problem.

Also did you add in the timeout I suggested? Please post your updated code. The only way the program can freeze up after the led turns off is if the serin command never gets a start bit. Any change of the serin line will look like a start bit so even garbage should keep it from freezing up.

Change your program to this:

Code:
X var word

pause 1000
high p17 'LED lights to show code has started running.
pause 500
low p17

start

toggle p17

serin p12, i9600, 200000, start, [Dec X] 'Radio data modem sends number (1,2 or 3) to activate corrisponing FET
If X = 1 then
high 10 : pause 1200 : low 10
elseif X = 2 
high 11 : pause 1200 : low 11
elseif X = 3
high 19 : pause 1200 : low 19

pause 500

endif

goto start


This should cause the led to toggle every 100ms if no data is received on the serial port. If data is received but it is garbage it will toggele every 500ms. If a valid command is received the delay will be 1700ms.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Serin won't run after shut down:
PostPosted: Fri Nov 04, 2011 4:33 pm 
Offline
Citizen

Joined: Fri Oct 28, 2011 4:18 pm
Posts: 7
Nathan,

Yes, I tried using a timeout early on, no luck. I'll try adding a manual reset and the code you indicated. But I've got the project buttoned up now so I'll have to wait until the weekend after next to look at it seriously again. I'm just going to program the chip an hour or so before it'll be put to use. It's working fine that way and I've tested it numerous times without a problem.

Thanks,

Scott


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO