BasicMicro - Forums

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

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Atom software reset?
PostPosted: Fri Nov 26, 2010 11:43 pm 
Offline
Master
User avatar

Joined: Tue Jul 07, 2009 9:06 am
Posts: 120
Location: Wisconsin USA
I can't seem to find a working reset command in the manual, essentially i want a software reset as an alternative to pressing the reset button.

Though i'm willing to use a transistor as a switch if need be, i just need a way to reset internally.
Right now i manually have to change all the values back, clear the lcd screen, and then manually repost the stuff.

This isn't specific to the Atom Nano, but the Atom in general, i just happen to be testing code using the nano at this time.

Kenjj, i'm going to send you some sample code once i get this all figured out.
Since i know you're gonna read this.

_________________
Image
Basic Micro Blog
Universal Robot Controller


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sat Nov 27, 2010 7:39 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
It usually is not hard to get a processor to reset, especially if you don't want it to. :lol:

I have not tried this, but on the Nano I would try something like:

Code:
RESET:
asm {
        ORG 0x500
        BCF PCLATH, 4
        BCF PCLATH, 3
        goto 0
}


Kurt


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sat Nov 27, 2010 3:09 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
That will restart the program but won't necessarily do what you want. A reset also causes certain registers to be reset and just jumping to address 0 won't do that. To force a reset you can cause the watchdog timer to reset by not clearing the watchdog timer. The watchdog timer is enabled on all Atom/Nano chips/modules so to cause a reset do this:

asm{
wdtloop
goto wdtloop
}

Assuming you haven't changed the watchdog timer multiplier this will cause the chip to reset in approx 18ms.

Note, you have to use inline asm code to do this because all basic code handles clearing the watchdog timer internally.

The AtomPro does not enable its watchdog timer by default. For those that want to do something similar on it they will have to enable the Watchdog timer and then do the same as above, except in H8 machine code.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sat Nov 27, 2010 3:52 pm 
Offline
Master
User avatar

Joined: Tue Jul 07, 2009 9:06 am
Posts: 120
Location: Wisconsin USA
Is there any way you could add a new command to the studio that will simply do a reset?
fullreset
or
softreset

It would goto line 0 and run the "clear" command automatically.
I just want a way to reset remotely, and it has to work on the nano and the pro.
As i said, i'm testing code on the nano, the final code will be on the pro.

_________________
Image
Basic Micro Blog
Universal Robot Controller


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sat Nov 27, 2010 4:21 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Eventually, but simply jumping to 0 and executing Clear doesn't do it. There are other registers Clear can't touch that would normally be reset. when a true reset happens.

Why exactly do you need a reset? Can't you just jump to the begining of your program and execute a Clear instruction? If you need to break out of a subroutine use the Exception command(eg exception label).

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sat Nov 27, 2010 6:24 pm 
Offline
Master
User avatar

Joined: Tue Jul 07, 2009 9:06 am
Posts: 120
Location: Wisconsin USA
A few reasons

A forced soft-reset incase of glitches.
I want to add a section to the code, that should something go wonky, i can always send a remote reset command.
So i can reset a bot without having physical access to it. Or have a bot reset itself.


Right now i'm testing some Menu select code, not very complicated, the menu select code will goto different labels depending on what i select.
I'd want to do a full reset, without using the reset button. I intend to use a pin-hole reset button that won't be easily pressed, and would only be used if it absolutely needed to be.

Anyways i don't really need to justify it, but it's something i'd use.
Pressing a reset button isn't always the easiest task when you have stacked boards, and tons of wires in your way, this much i know from experience.

After i comment it, i'll post my sample code, so you can see where i'd want it.

_________________
Image
Basic Micro Blog
Universal Robot Controller


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sun Nov 28, 2010 4:42 am 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
I have been emailing with Clover about this. For the nano(X) and Atom modules, there is the old TIMEWATCHDOG command. This appears in the old version 3.002 manual, which was for PICs only. When your program reaches this, it stops reseting the watchdog counter. This counter eventually reaches its limit, and a reset is forced on the PIC. This is still in the compiler; I wrote some small code to test if this command is still working, and it is. Now you have ASM code to do it.

This doesn't work with Pros.

Clover seems to want to use this to implement a loop. I have advised her to use a simpler mechanism, but I may not entirely understand her thinking yet. And so it goes. ;)

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sun Nov 28, 2010 12:05 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
I'm not asking you to justify it, Fallentine. I'm asking you to tell me what you need it to do. if all you need to do is restart your program from the begining and don't really care if every register in the chip is at its reset state, then just use the exception command to jump to the begining of your program. make sure you program init intiilizes all your variables however you need them to be on startup and you are good.

If you are using special hardware functions then you may need a true reset. You may be able to use the timewatchdog but that was designed for something else(eg it changes the WDT timer multiple so the reset takes longer so you can get a better reading on the speed of the processor which can be used to calculate the temperature). You are better off with the simple asm loop I gave above to cause a watchdog timeout(which will cause a real reset).

There is a third option. If your bot is attached to the PC then clicking connect on the terminal window will send a reset to the board as well(for those that didn't know). While connected you can also send resets by clicking the reset button in the terminal window. This just sends a reset pulse down the RTS and DTR pins(depending on which are activated in Preferences).

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sun Nov 28, 2010 12:14 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
There is also probably a fourth option. That is you could simply attach a more assessable reset button. For example if you look at the Arduino platforms, just about every shield I have seen has it's own reset button and also usually it's own power LED...

Just a thought...

Kurt


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Sun Nov 28, 2010 8:45 pm 
Offline
Master
User avatar

Joined: Tue Jul 07, 2009 9:06 am
Posts: 120
Location: Wisconsin USA
I'd need a true reset. At the current state of my program, adding a label to the very top followed by Clear, would work, but later on i may need a true reset. Doing the same as you'd get from pressing the reset button, this is why i'm not opposed to using an external device. A relay would work, but i want to avoid that due to their size.

Making the button more accessible is good thinking, but it's when having the bot out of arms reach, a button wont cut it.
I'd want a way to reset it remotely.
IE i send a code-word to the bot, and should the bot receive this codeword it'll initiate the reset.

Quite literally
Controller
Code:
;Normal programming here

if (in0 = 0) then  ;button on p0 pressed down on controller
Hserout [dec 911]
endif
;normal programming after this.


bot
Code:
Hserin [dec OMG]

if (OMG = 911) then
softreset
endif


So if i send 911 to the bot, it'll do a soft reset. If you can make this happen by using a command that triggers the watchdog timer that's fine.
I'm just getting confused with all the discussion of the watchdog stuff. I still don't know exactly what i'd have to do to initiate the reset using a watchdogtimer.
Keep in mind, i'm not very good at programming, but my if/then/else programming is fine.

I just want a way to reset the chip incase i overextend a servo again, or if the programming has an unexpected reaction. I'd want to be able to reset it quickly, FROM the controller. I may even go as far as to use a dedicated micro controller, to work as a safety.
IE the secondary MCU and the main MCU would both read the serial input from the wireless device, but the secondary would only react to special commands, that the main MCU would simply ignore. Daisy Chain MCU's.
Infact this may be the safer route. Incase the main MCU completely freezes up or goes into an infinite loop. I'd still need some sort of electronic switch. I'd use a transistor if it would work.

Example of usefulness.
You guys used to watch that show robot arena or what ever right? Where people would make big remote robots to destroy other robots?
What if your bot freezes up there, or goes into a loop or gets stuck. Wouldn't you want a way to reset it remotely so your bot doesn't get hammered by a bot nicknamed: The Delivery Boy.

_________________
Image
Basic Micro Blog
Universal Robot Controller


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Mon Nov 29, 2010 7:48 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Sounds good. However the main problem that I see is that if your program is truly hung or simply in a loop waiting for the servo move to finish, it most likely won't receive your data to do the reset. This is unless you can do something to cause an interrupt.

Not knowing what you are using as a remote it is hard to say what might work. For example if you are plugging in something into the RS232 type circuit such as a bluetooth can you control the DTR or the like possibly one of your best bets would be use this to cause the reset (Nathans number 3).

If you add external hardware, there may be many ways for you to do this. Could hook it up to pull the reset line down. Could connect it to an IO pin on the processor that has the ability to generate an interrupt and have a simple interrupt handler that resets the processor.

If you are using an XBEE you might be able to have the remote be able to set/clear one of the IO pins of the XBEE to toggle this state (Note: Xbee are 3.3v so... )

My guess that jumping to address 0 or the code I put up on Lynxmotion would probably do a sufficient reset for you. There may be a few states that are not reset, but my guess is the startup code for the BAP/Nano resets a sufficient amount for the majority of your cases.

Good Luck
Kurt


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Mon Nov 29, 2010 11:27 am 
Offline
Master

Joined: Tue Jun 22, 2010 1:15 pm
Posts: 203
If there are two RS-232 handshake lines available, one being used for programming, the 2nd could be used for a reset circuit.

Alan KM6VV

_________________
Visit:
http://groups.yahoo.com/group/SherlineCNC/
http://tech.groups.yahoo.com/group/HexapodRobotIK/


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Mon Nov 29, 2010 11:35 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
So in this case I think Kurt is right. You need an emergency stop reset(one you can gaurantee will work) more than a software reset(which you can't gaurantee will work if the program hangs).

So if you'll tell us what you are using to control the bot remotely that would give us a better idea of what you have to work with. If it's something like an IR remote, then I think software reset is your only option. If its an RC radio or wireless serial port(like XBee) then you have some options. A channel from the wireless radio could be connected to a bit switch to toggle the reset pins. As for XBee I think you should be able to control its input/output state on one of it's I/Os, Then you just output low to reset and input to have reset released. This should work even though the XBee is 3.3v because it never goes high.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Mon Nov 29, 2010 4:13 pm 
Offline
Master
User avatar

Joined: Tue Jul 07, 2009 9:06 am
Posts: 120
Location: Wisconsin USA
Bluetooth uart adapters for robots.

Eventually The Roving networks RN-41 for the robot, RN-24-E for the controller.

However i do plan on using IR for a couple smaller lower cost projects.
This is where some sort of software reset would be handy.

But this is just starting to get.. overwhelming, soo, forget about the software reset. I can live without it.
The thread title was misleading anyways, i really wanted a software controlled reset. External components welcome.

Right now i just put a label at the very top of the program followed by CLEAR, and when ever i want a reset, i just goto that label. It seems to be working for my simplistic programs and i haven't had any problems yet.

Now then, What do i need to do, to the ATN on the Pros, to cause a reset there. Give me hookup details.
Do i just connect an IO pin to it? Even an IO pin from another MCU? IF i do that, what do i need to send out that IO pin to cause a reset?
Using an 8 pin PIC/Bluetooth Adapter as a safety MCU seems like my best option right now. It can force a reset even if the main MCU locks up or goes into an infinite loop.
Since all the roving networks bluetooth adapters accept commands that have some control over the extra IO pins.
Will pulling high, 5v on the ATN pin be enough on the PRO's?

Also, what can i do to reset a nano from another MCU/Bluetooth adapter? How do i wire this up?

_________________
Image
Basic Micro Blog
Universal Robot Controller


Top
 Profile  
 
 Post subject: Re: Atom software reset?
PostPosted: Mon Nov 29, 2010 5:07 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
The ATN pin is designed for direct conenction to RS-232 voltage levels(eg its inverted and wants +- voltage imputs). If you are using the I/Os from a bluetooth adapter I suggest you use the RST pin directly instead. RST is TTL level. A low on RST pin will reset the processor.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


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

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