BasicMicro - Forums

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

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: BasicATOM Nano 8 as some kind of networked slave
PostPosted: Sat Aug 13, 2011 3:36 pm 
Offline
New User

Joined: Mon Aug 08, 2011 7:54 am
Posts: 2
I've worked my way through the manuals and the forum posts, but I'm still unclear about my options for the following project:

I need a small device to control a single (RC) servo in response to commands issued from another microcontroller (in this case a dsPIC.) The dsPic master would issue commands telling the slave to move the servo to a stated position and hold there or sweep back and forth at a stated rate (and arc.) The project will initially require two of these slaved controllers (approximately 2-4 meters apart) and add more later (one servo per controller.) The length of the cable run from the master to the slaves won't exceed 10 meters.

I ordered and am waiting for 2 Nano 8's and Nano 8 pin Microcontroller Boards. I was attracted by the low cost and potentially low parts count of this approach.

Based on the data sheet, it appears that Hardware PWM is available on the Nano 8 (though this isn't reflected in the 'HPWM Capable Pins' table in the reference manual.) The reference manual states that HSERVO is not supported for the Nano, but it should be reasonable to code the problem using PWM.

My real challenge is how to network the Nano 8's. My three candidates appeared to be:
- I2C
- SPI
- Traditional Serial (e.g. RS232)

Initially, I imagined using the Nano 8 as an I2C slave, but this does not appear to be straightforward, even if it is an option (I read this post http://forums.basicmicro.net/atomnano-f485/i2c-slave-mode-on-nano-t9463.html but was unable to build the .bas file.)

SPI is noted in the reference manual as stating "SHIFTIN and SHIFTOUT only work as a master device..." This appears to be a deal-killer for using SPI.

I could up the parts count and add a MAX232 to each of the Nano 8's and use Software Serial. However, I'm fuzzy on a few points relating to this approach:
- No UART on the Nano 8 seems to preclude using HSERIN.
- The data sheet refers to Software Serial and references the AUSART. I'm not clear on the use of the AUSART, any pointers to relevant docs would be useful.
- Does the single SER pin, as multiplexed to the TXD/RXD RS232 lines in the programming configuration, work with a traditional Serial (2-pin) model?
- Is the SER pin available as one of two pins for a two-pin approach? Does it have to be one or the other?

In any event, I'd be grateful for any observations, suggestions or help regarding the use of the Nano 8 for this project.


Top
 Profile  
 
 Post subject: Re: BasicATOM Nano 8 as some kind of networked slave
PostPosted: Tue Aug 16, 2011 9:49 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
There is one CCP pin on the Nano8 so yes you can do hardware PWM. I think HPWM will work correctly with it. I'll have to double check that. If not you can manually setup the CCP pin registers to run a PWM signal. However a servo pulse is 0 to 3ms duty with 20ms period. Thats a 50hz update rate. The slowest PWM on the Nano(at 8mhz) is 448hz. So you can't use PWM to produce the Servo pulse. You can however produce the servo pulse using 1. A timer interrupt and the Compare match feature of the CCP pin. You setup a timer1 interrupt to overflow 50 times a second. On the interrupt you set the servo pin high, then set the compare match to turn the pin low after the required number of clockcycles. This allows you to produce a 50hz servo pulse almost entirely in hardware(the pulse itself will be accurate to a single clock cycle.)

Once you have that thenb you will have to figure out how to communicate to the Nano8. I suggest a read only SPI style communciations. This will require a clock pin, a data pin and if you plan on using more than one nano8 to run servos, a chip sel pin. The Nano8 has no hardware communications capabilities built in. You will need to manually code the nan8s SPI communications because the shiftin/out commands are master only commands. Also using serin/serout won't work very well because the timer1 interrupt will cause glitches with the bitbanged serial.

To put it simply, this is a completely doable project, however it is not simple and will require assembley code to do it(at least for the interrupt handler).

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: BasicATOM Nano 8 as some kind of networked slave
PostPosted: Tue Aug 16, 2011 12:42 pm 
Offline
New User

Joined: Mon Aug 08, 2011 7:54 am
Posts: 2
Thanks for the response! I'm really excited about the Nano 8 and the two boards offered specifically for it. I'm now staring at a lot of my other projects contemplating how to add this startlingly low-cost computational power.

No big surprises on the options for PWM and comms. Your description of the mechanism for producing PWM via the timer is very helpful. The SPI approach makes sense as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

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