Hi!
Thanks a lot for your fantastic help! PWM works now on a node, which is
remote controlled by radio. I just used 

TOSH_ASSIGN_PIN(MOTOR1DIR, C, 1);
TOSH_ASSIGN_PIN(MOTOR1PWM, B, 5);
TOSH_MAKE_MOTOR1PWM_OUTPUT();
TOSH_MAKE_MOTOR1DIR_OUTPUT();
TOSH_CLR_MOTOR1PWM_PIN();
TOSH_CLR_MOTOR1DIR_PIN();

instead of

outp(0x20, DDRB);

and there were no conflicts with radio anymore.

BiBe



> -----Original Message-----
> From: Michael Schippling [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 26, 2006 6:19 AM
> To: BiBe
> Cc: [email protected]
> Subject: Re: [Tinyos-help] Problems with GenericComm and PWM
> 
> Oh, now you're going to make me work AND explain what I did...oy...
> 
> First I stole my PWM stuff from Sarah B's cotsbots board code that 
> uses different pins and a somewhat different idea, vis motor direction.
> I then left the direction pin defs in but never used them, so at least 
> three layers of confusion can ensue...my code is for the mica cards 
> themselves.
> 
> Second here's a quote from a previous post that might help explain the 
> macros:
> 
>  >> Ian Welch wrote:
>  >> I was wondering where I could find the TOSH function commands. I'm 
> going through the CC1000 modules in hopes to write my own drivers. Was 
> wondering what command like " TOSH_MAKE_CC_CHP_OUT_INPUT() " and "
> TOSH_SET_CC_PCLK_PIN() " do. I have an idea on what these functions do 
> but would I like to know the details. I'm guessing there is a file 
> locate somewhere that gives all these function. Where I might I find this
file.
>  >>
>  >> Thanks,
>  >>    Ian
>  >>
> > They are generated by a macro mechanism that run two or three levels 
> > deep, so there is basically no hope of finding the actual definition 
> > without searching on each _*_ sub-string.
> > Good luck with that...
> >
> > In any case there is one more missing component you haven't stumbled 
> > over yet (this is not the real definition, I just pulled it out of a 
> > hat as an example....):
> >
> > // assign the name "CC_CHP_OUT" to port C, pin 0
> > TOSH_ASSIGN_PIN( CC_CHP_OUT, C, 0 );    // PC0
> >
> > Then your initial puzzles:
> > // set CC_CHP_OUT pin to Input mode (can also use _OUTPUT)
> > TOSH_MAKE_CC_CHP_OUT_INPUT()
> > // (after using TOSH_MAKE_CC_PCLK_OUTPUT) set pin to high
> > TOSH_SET_CC_PCLK_PIN()
> > // or, e.g., clear to low
> > TOSH_CLR_CC_PCLK_PIN()
> >
> > The TOSers did a pretty good job of keeping the pin names the same 
> > as those on the schematic, which are of course slightly different 
> > from those in the ATMEGA manual. But once you get over the hump it's 
> > not too hard to intuit.
> >
> > MS
> >
> >
> 
> So basically, from the above you should be able to intuit the TOS 
> mechanism for assigning pins, names, and levels. So you need to make 
> the PortB pins that can do PWM into outputs by diddling the right BITS 
> on DDRB, which is done with the TOSH_MAKE_*_OUTPUT() macro, and do all 
> the other PWM setup. This is done in the init() method of my 
> HPLMotorIIM.nc file, but only so as to do the exact thing I wanted, so 
> your pulse rates may change.
> 
> Was that enough gobbledegook to get you going?
> MS
> 
> 
> 
> 
> BiBe wrote:
> > Hi!
> > Thanks a lot for your answer!
> >
> > With the DDRB register, I set the output pins for PWM. In your code,
> this is
> > done by:
> >
> > TOSH_MAKE_MOTOR1PWM_OUTPUT();
> > TOSH_MAKE_MOTOR1DIR_OUTPUT();
> >
> > TOSH_CLR_MOTOR1PWM_PIN();
> > TOSH_CLR_MOTOR1DIR_PIN();
> >
> > Where are those functions defined and how can I use them to get PWM 
> > to
> Port
> > OC1A and OC1B? Can I even use these functions without having the 
> > cotsbots-board?
> >
> > Furthermore I found that in a header file:
> >
> > /** after cotsbots motor/hardware.h for PWM output: **/ // it 
> > appears that the PWM and DIR appellations are reversed //  and also 
> > that the pins assigned to PWM (sic) are not available //  due to 
> > their being used by the radio:
> > //      PB1 -- SPI_SCK
> > //      PB2 -- SPI_MOSI
> > //  so gotta try somethong else....
> >
> > TOSH_ASSIGN_PIN(MOTOR1DIR, C, 0);       // PC0
> > TOSH_ASSIGN_PIN(MOTOR1PWM, B, 6);       // PB6
> >
> > TOSH_ASSIGN_PIN(MOTOR2DIR, C, 1);       // PC1
> > TOSH_ASSIGN_PIN(MOTOR2PWM, B, 5);       // PB5
> >
> > So there seems to be problems to use radio and PWM together, because 
> > of corporate use of PB registers.
> >
> > Can I use TOSH_ASSIGN_PIN() without cotsbots-board in nesC? I tried 
> > to compile and there were no errors. But will it work expectedly or 
> > do I
> have
> > to use any more header files like hardware.h?
> >
> > Thanks a lot,
> > BiBe
> >
> >
> >
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED] 
> >> [mailto:tinyos-help- [EMAIL PROTECTED] On Behalf Of 
> >> Michael Schippling
> >> Sent: Tuesday, July 25, 2006 6:14 AM
> >> To: Birger Becker
> >> Cc: [email protected]
> >> Subject: Re: [Tinyos-help] Problems with GenericComm and PWM
> >>
> >> sbi() and cbi() should work fine, as long as you are careful to not 
> >> touch pins used by the radio. I wouldn't go writing whole registers 
> >> with outp() if there is any shared pins.
> >> Double check the schematic for the mote you are using to make sure.
> >>
> >> I have some PWM code in my code bolus:
> >>      http://www.etantdonnes.com/Motes/robocode.tar.gz
> >> I forget what reg DDRB is, but I use the timer/counter pins on the 
> >> ATMEGA 128 so either I did something right, or you don't need to 
> >> touch DDRB...
> >>
> >> MS
> >>
> >>
> >>
> >> Birger Becker wrote:
> >>> Hi!
> >>> I'm currently programming PWM (pulse width modulation) on an 
> >>> ATMega
> 128
> >> in a
> >>> tinyOS-environment. Programming of PWM is ready, but now I wanted 
> >>> to
> >> remote
> >>> control one Mote with the PWM by another, which is connected to a 
> >>> programming board.
> >>>
> >>> So I used TOSBASE and SimpleCmd for basic and put my PWM code in 
> >>> the command-process of SimpleCmd. The TOSBase-Mote is then 
> >>> administrated
> by
> >>> programming board using UART and it sends commands via 
> >>> RadioCRCPacket
> to
> >>> SimpleCommand, which receives them by GenericComm. The remote 
> >>> control
> >> works
> >>> fine, I checked by LEDs.
> >>>
> >>> To realize PWM, I used register DDRB of ATMega 128 to set output-Pins.
> >> But
> >>> when any bit of this register is set to 1, no Radio-Packets will 
> >>> be
> >> received
> >>> anymore.
> >>>
> >>> Code like outp(0x20, DDRB) (in tinyOS 1.1.0) and manually set bits 
> >>> by
> >> sbi()
> >>> and cbi() (in tinyOS 1.1.11) results the same curious effect.
> >>>
> >>> How does GenericComm or RadioCRCPacket use DDRB-register and how 
> >>> can I
> >> use
> >>> PWM-ports without getting every Radio-Connection crashed.
> >>>
> >>> Many thanks,
> >>> BiBe
> >>>
> >>>
> >>> _______________________________________________
> >>> Tinyos-help mailing list
> >>> [email protected]
> >>> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tiny
> >>> os-
> >> help
> >> _______________________________________________
> >> Tinyos-help mailing list
> >> [email protected]
> >> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyo
> >> s-
> help
> >
> >



_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to