Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
alexru
PostPosted: Nov 29, 2010 - 11:45 AM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

newjou wrote:
If Zigbit send an impuls of
- 1mS Servomotor turn in right way for example
- 2mS Servomotor turn in left way
So direction is controlled by impulse width? What kind of servo it is?

Where did you get such approach to controlling robots in general? It is somewhat unorthodox and I have doubts that it will work at all.

newjou wrote:
As I don't have a particular DATASHEET of Zigbit (PORT, timer, interrupt)I takes me too much time to manipulate Zigbit.
ZigBit has atmega1281 inside, datasheet for it is available.


Macros for manipulating GPIOs are located in gpio.h file. Or you can use regular AVR instructions to access ports. There is nothing specific to BitCloud.

BitCloud application timers have 10 ms resolution, so you need to use hardware AVR timers, nothing specific to BitCloud either.

So basically feasibility of the project depends on how familiar you are with AVRs.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
newjou
PostPosted: Nov 29, 2010 - 12:59 PM
Rookie


Joined: Oct 02, 2010
Posts: 39


Quote:
So direction is controlled by impulse width? What kind of servo it is?

exactly. I use a S3003 FUTABA. I modified the servo wich normaly rotate 180° so that it make a full rotation. The command of the robot depends on the type of engine who pulls it.
Quote:
ZigBit has atmega1281 inside, datasheet for it is available.
I have Datasheet but it is difficult to adapt intruction of ATMEGA1281 to zigbit taht is why i asked for a simple code wich show me how to use
DDxn: to set direction of pin
PORTxn: to set the state of output
sei: Enable or disable interrupt
OC0A: Output compare for timer
TIFR0: timer Interrup flag
TCNT0: timer counter register
Configure frequence, Watch dog...
In fact i can use it in a regular atmega controler.
Quote:
Macros for manipulating GPIOs are located in gpio.h file. Or you can use regular AVR instructions to access ports
I am afraid to modifie that file I wanted to use all instruction in the same file. Here is a part of code in gpio.h where i found DDR and PORT register
Code:
#define HAL_ASSIGN_PIN(name, port, bit) \
INLINE void  GPIO_##name##_set()         {PORT##port |= (1 << bit);} \
INLINE void  GPIO_##name##_clr()         {PORT##port &= ~(1 << bit);} \
INLINE uint8_t  GPIO_##name##_read()     {return (PIN##port & (1 << bit)) != 0;} \
INLINE uint8_t  GPIO_##name##_state()    {return (DDR##port & (1 << bit)) != 0;} \
INLINE void  GPIO_##name##_make_out()    {DDR##port |= (1 << bit);} \
INLINE void  GPIO_##name##_make_in()     {DDR##port &= ~(1 << bit); PORT##port &= ~(1 << bit);} \
INLINE void  GPIO_##name##_make_pullup() {PORT##port |= (1 << bit);}\
INLINE void  GPIO_##name##_toggle()      {PORT##port ^= (1 << bit);}


Quote:
BitCloud application timers have 10 ms resolution, so you need to use hardware AVR timers, nothing specific to BitCloud either.

I will finaly use an other contrôler for servomoteur to generate timer. The input to genrate timer will be connect to GPIO as "0" or "1" output.
The Zigbit will be use for communication. That way I think i can go faster than using Zigbit for 1ms impuls

If it is possible, I will just need a basic application to set I/O in the same file of my projet and avoid as much as possible modifiying and other file

Thank you
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Nov 29, 2010 - 01:11 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

Quote:
but it is difficult to adapt intruction of ATMEGA1281 to zigbit
You don't need to adapt anything, just use them as you would use them regularly.

Quote:
sei: Enable or disable interrupt
This should not be done, global interrupt enable flag should be enabled at all times. Use individual modules interrupt enable flag to control interrupts from them.

Quote:
I am afraid to modifie that file
You don't need to.

Code:

#include <gpio.h>

GPIO_1_make_out();
GPIO_1_clr();
// etc


Quote:
If it is possible, I will just need a basic application to set I/O in the same file of my projet and avoid as much as possible modifiying and other file
You don't need to modify anything, just add your code to blink or another application.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
newjou
PostPosted: Dec 01, 2010 - 12:17 AM
Rookie


Joined: Oct 02, 2010
Posts: 39


Thank you sooo much.

I noticed that "void APL_TaskHandler(void)" is the main of aplication, whithout it, no compilation is possible!
I removed all instruction inside "APL_TaskHandler" and all other function exept ZDO function because when I remove ZDO function the compilation is not possible.
I set up my own I/O so I can light a LED, create my own blink application with or whithout timer.
How many time last one intruction? (One cycle intruction is 4 clok periode in a regular controler).

I set interrupt but it does'nt work this is how I did
Code:
#include <irq.h>
#define   interruption   GPIO_IRQ_7_read()
void APL_TaskHandler(void)
{
IRQ_FALLING_EDGE; // interruption actif à l'état bas
int HAL_EnableIrq(HAL_IrqNumber_t GPIO_IRQ_7);// autoriser les interruptions   
if(interruption==0)
interrupt(); }

interrupt() has the instruction in case of interrution in falling edge. Please where is wrong inside?

I have an other problem wich is not really disturbing. when I compil I have this message "Coordinator: Error when trying to make JTAGICE target device enter programming mode and Coordinator: error loading object file" but when I "clear current configuration (F12) in AVRSTUDIO" the compilation is good. Is it possible to cancel this error?
I will now set nework between Zigbit
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Dec 01, 2010 - 06:07 AM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

newjou wrote:
I set interrupt but it does'nt work this is how I did
Code:
#include <irq.h>
#define   interruption   GPIO_IRQ_7_read()
void APL_TaskHandler(void)
{
IRQ_FALLING_EDGE; // interruption actif à l'état bas
int HAL_EnableIrq(HAL_IrqNumber_t GPIO_IRQ_7);// autoriser les interruptions   
if(interruption==0)
interrupt(); }

interrupt() has the instruction in case of interrution in falling edge. Please where is wrong inside?
Start by learning C, I don't even know where to start commenting that code, it is wrong from the top and all the way through. It should not even compile. Or read how it is done in BSP.

newjou wrote:
I have an other problem wich is not really disturbing.
You should really resolve first problem first.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
newjou
PostPosted: Dec 06, 2010 - 09:12 PM
Rookie


Joined: Oct 02, 2010
Posts: 39


Hello,

After getting more information from BSP I had instruction to set interruption. I could not run it because of the last instruction to enable interruption after the interrupt function is exécute.


Code:
   #include <irq.h> // header for interrupt
#define BSP_readKEY0() GPIO_IRQ_6_read() // PORT interrupt select

// In the APL_TaskHandler
{
HAL_RegisterIrq(IRQ_6, IRQ_LOW_LEVEL, bspKey0InterruptHandler); // interrupt config
   HAL_EnableIrq(IRQ_6);// enable interrupt
}

void bspKey0InterruptHandler(void)//  run this function in case of interruption
   {
     HAL_DisableIrq(IRQ_6);// disable interrupt
   GPIO_0_toggle();   // INSTRUCTION
   intervaltimer /=2;
  bspPostTask0(BSP_BUTTONS);// Clr interrupt flag                  
   }


Please wich argument can I send to bspPostTask0(xxxx);instead of BSP_BUTTONS?
Is it automatic that an action in BSP_readKEY0()will set the interruption or I need to read it first in APL_TaskHandler?

Thanks
 
 View user's profile Send private message  
Reply with quote Back to top
newjou
PostPosted: Dec 07, 2010 - 12:35 AM
Rookie


Joined: Oct 02, 2010
Posts: 39


HELLO AGAIN!!!Smile

I m really please to handle a Zigbit module thank to your great help. Very Happy
As the resolution of Zigbit is 10mS, I used a PIC contrôler to drive Servomotors (1ms and 2 ms) using a timer and it works very well now (foward, bakward, left right). I will used USART (13 - 14) of Zigbit to exchange DATA between both controler.

According to network, I will be learning how to light a LED from one Zigbit to an other like I did with AT command.

Between all sample application of bitcloud, wich one is best describe to esealy be modifie for this purpose( I am using one coordinator and 3 router)


Thanks
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Dec 07, 2010 - 06:49 AM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

newjou wrote:
bspPostTask0(BSP_BUTTONS);// Clr interrupt flag
It is not "Clr interrupt flag" it. This functions tells task manager to schedule and run BSP task. That task will check if button is released and will re-enable an IRQ.

newjou wrote:
Please wich argument can I send to bspPostTask0(xxxx);instead of BSP_BUTTONS?
Any you want, given that you'll also provide corresponding task handler function.

newjou wrote:
Is it automatic that an action in BSP_readKEY0() will set the interruption or I need to read it first in APL_TaskHandler?
I don't understand you here. BSP_readKEY0() just reads current state of pin, that's all.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
alexru
PostPosted: Dec 07, 2010 - 06:52 AM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

newjou wrote:
As the resolution of Zigbit is 10mS,
Resolution of application timers is 10ms, you still can use hardware timers as you did on PIC and get whatever resolution you like.

newjou wrote:
Between all sample application of bitcloud, wich one is best describe to esealy be modifie for this purpose
They all will require modifications, but closest ones are Peer2Peer and LowPower, I guess.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
newjou
PostPosted: Dec 08, 2010 - 09:01 AM
Rookie


Joined: Oct 02, 2010
Posts: 39


Hello!
After reading samples applications, I found that "lowpower" is interresting for sending data from coordinator to end device.
But config depends on MESHBEAN board which defines the role of each board by short adress config by dipswitch. As lowpower has 3 files (end device, coordinator and lowpower) but only one .srec to fire the zigbit, please how can I create only 2 projects (one for coordinator and one for router) with generates their own .srec file without loosing AVR parameter? . I also want to avoid a modification inside configuration and Makefile related with lowpower application.
The solution I adopt was to modified peer2peer because it only has 1 file. I can do 2 copie


My second great need is to include lest file in one projet and configure all parameter in the same file.
Here is the parameter of coordinator. Please, how can set //Data request ATX0 and joining procedure WJOINI
at the end of this code? (please also have a look on my coordinator config
Code:
void init_coordinator (void)
{
CS_DEVICE_TYPE_ID=0                 // WROLE=0 --> 0for coordinator  (1 if router)
CS_NWK_ADDR_ID=0                    // WSRC=0 --> local adress for coordinator  "1" for the first router "2" for the second...
CS_EXT_PANID = 0xAAAAAAAAAAAAAAAALL //WPANID=0x---LL.. Was 1234 in AT command
CS_MAX_CHILDREN_AMOUNT   3          // 3 Router are used for project
CS_NEIB_TABLE_SIZE = 3              // Each router has 3 device???
CS_MAX_CHILDREN_ROUTER_AMOUNT = 0   // Coordinator has no parent router will have 1
CS_ROUTE_TABLE_SIZE = 3             // 3 report be sent to coordinator "0" for router
CS_END_DEVICE_SLEEP_PERIOD = 10000  // Not necessary bcs no end device
CS_CHANNEL_MASK = 40000             // WCHMASK=40000
CS_CHANNEL_PAGE = 0                 // WCHPAGE=0 BPSK modulation
CS_RX_ON_WHEN_IDLE = true           // Never sleep because coordinator
CS_NWK_UNIQUE_ADDR_ID = false       // Be avoid
// No security
// ATX0                          //
// AT+WJOIN

}
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Dec 08, 2010 - 01:05 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

Generally there will be no easy path, you'll have to understand how things work. LowPower is not bound to MeshBean, if you study code you'll find that there is a way to make LowPower to use defined value instead of switches.

Again, your code is not valid C code. As for parameters values:
Code:

CS_MAX_CHILDREN_AMOUNT   3          // 3 Router are used for project
CS_MAX_CHILDREN_ROUTER_AMOUNT = 0   // Coordinator has no parent router will have 1
Comments and values are contradicting each other, I don't know which is valid.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
lst111
PostPosted: Jan 13, 2011 - 02:41 PM
Newbie


Joined: Jan 13, 2011
Posts: 7


Hey guys!I`m testing Zigbit modules. I was reading what You wrote here and I`ve got a question. How can I get this different code you show. I know how to test, bootload modules but never changing and write any code. Is there any Zigbee profiles i can get somewhere or build on my own and load that on modules adding that to Zigbee stack?? What language it support? How it works? is it only a application layer code kinda script? Thank You in advance for Your help.
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Jan 14, 2011 - 06:12 AM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

Download SDK and look what sample applications there are. They all written in C.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
lst111
PostPosted: Jan 14, 2011 - 09:55 AM
Newbie


Joined: Jan 13, 2011
Posts: 7


Thank You Alex. Could You explain me in short how can I load that to my Zigbit modules. Is it possible to do that by this bootloader I`ve used to load serialnet? Sorry I`m not good programmer I know so so C but I don`t have a clue how put code into my modules( I suppose sth to do with makefile;)) Really appreciate Your help.
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Jan 14, 2011 - 11:51 AM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

lst111 wrote:
Thank You Alex. Could You explain me in short how can I load that to my Zigbit modules.
Before loading you need to compile applications, and it is not trivial to explain. In a few words: you need to run "make clean all" in the directory with Makefile in it. But you need to understand what you are dong to read possible error messages.

lst111 wrote:
Is it possible to do that by this bootloader I`ve used to load serialnet?
Yes, after compiling you'll get .srec file.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Ludo
PostPosted: Jan 14, 2011 - 02:12 PM
Newbie


Joined: Jan 14, 2011
Posts: 8


Hi,

I begin a test with Zigbee, I have a RAVEN kit and one Zigbit module ATZB-24 A2 (dual chip antenna)
I have programed (JTAG) the AT90USB1287 with BitCloud_ATAVRRZRAVEN_1_10_0 WSNDEMO code to set this stick in coordinator and one of RAVEN module in router mode and the last in end-device.
When I run WSDEMO, my network is drawing correctly.
Now I want include my Zigbit module in this network, I program it with BitCloud_ZIGBIT_1_10_0 to set my module in End-Device mode.
When my zigbit start, the LED blink and staying 'on' (according to the documentation, the module have join the network) but the end-device isn’t appeared in WSNDEMO.

For information:
- For the Zigbit module, I have just plug the power supply, the JTAG and 1 LED on GPIO0
- I have the same CS_EXT_PANID = 0xAAAAAAAAAAAAAAAALL
- And I have added this code in WSNDemoApp.h
Code:

#undef _TEMPERATURE_SENSOR_
#undef _LIGHT_SENSOR_
#undef _BATTERY_SENSOR_
#undef _SLIDERS_
#undef _BUTTONS_
#undef _LCD_

Can you say me if it’s possible to display this module in WSNDEMO and if my approach is the good one?
Thank in advance.
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Jan 14, 2011 - 03:11 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

Ludo wrote:
When my zigbit start, the LED blink and staying 'on' (according to the documentation, the module have join the network) but the end-device isn’t appeared in WSNDEMO.
It probably assumed the role of coordinator and started new network. You need to change APP_DEVICE_TYPE if you don't have sliders.

Ludo wrote:
And I have added this code in WSNDemoApp.h


Also add "#define OMIT_READING_SENSORS".
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Ludo
PostPosted: Jan 14, 2011 - 03:17 PM
Newbie


Joined: Jan 14, 2011
Posts: 8


Thanks for your quick answer !
I have already change the APP_DEVICE_TYPE = DEV_TYPE_ENDDEVICE
I will try to add “#define OMIT_READING_SENSORS"
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Jan 14, 2011 - 03:24 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4861
Location: San Jose, CA

Ludo wrote:
Thanks for your quick answer !
I have already change the APP_DEVICE_TYPE = DEV_TYPE_ENDDEVICE


To check if it is really end device disable all other nodes and this one should continuously blink.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Ludo
PostPosted: Jan 14, 2011 - 03:39 PM
Newbie


Joined: Jan 14, 2011
Posts: 8


yes it's the case, when I stop the coordinator, the LED blinking
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits