arduino micro radio multi-channels PWM using attachinterrupt.

45 views
Skip to first unread message

Fu Na

unread,
Mar 31, 2015, 11:51:22 PM3/31/15
to not-just...@googlegroups.com
I'm using arduino micro.My purpose of writing the code is to use the attachinterrupt to interrupt the input signal and transfer the interrupted signal to output pin for each channel, I need to do 6 channel in total.

Example: for channel 3, the signal at input pin2 =the signal at output pin4.

Problem:Using the code i attached,i can get the desired output signal (same pulse width as input signal)for channel 3 only,but the duty cycle becomes smaller  which means the period of PW is longer for output.For channel 1 there is no any output signal .
PCintPort:attachInterrupt(1,calcThrottle,CHANGE);
I also do not understand why the above code use only 1 ":" in order for me to get the wanted output signal., 
PCintPort::attachInterrupt(1,calcRoll,CHANGE);
but here i have to use 2 "::" in order to compile the code successfully.
READING_PWM_SIGNAL_1.ino

Adrian Godwin

unread,
Apr 2, 2015, 3:29:51 AM4/2/15
to Fu Na, not-just...@googlegroups.com
What is the frequency and duty cycle of the signals ?


--
You received this message because you are subscribed to the Google Groups "Not Just Arduino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to not-just-ardui...@googlegroups.com.
To post to this group, send email to not-just...@googlegroups.com.
Visit this group at http://groups.google.com/group/not-just-arduino.
For more options, visit https://groups.google.com/d/optout.

Daniel "yOPERO" Garrido

unread,
Apr 2, 2015, 6:21:55 AM4/2/15
to not-just...@googlegroups.com, naven...@gmail.com
The single and double colon has to do with scope

C++[edit]

class A 
{
  static int i;  // scope of A
};
 
namespace B
{
  int j;
}
int A::i = 4; // scope operator refers to the integer i declared in the class A
int B::j = 2; // scope operator refers to the integer j declared in the namespace B

I think in the setup you should be using double colon to ensure that the resolution occurs from the global namespace.

Fu Na

unread,
Apr 2, 2015, 8:54:56 PM4/2/15
to not-just...@googlegroups.com, naven...@gmail.com
The input signal is :pulse width-1.5 ms,period-16ms(from one falling to next falling).
The output signal is :pulse width-1.5 ms,period-20ms.

在 2015年4月2日星期四 UTC+8下午6:21:55,Daniel "yOPERO" Garrido写道:

FU NA

unread,
Apr 13, 2015, 4:44:23 AM4/13/15
to not-just...@googlegroups.com
Hi,Mr. Goh,is it ok if I use the processing app to do the serial communication instead of the turbo c++?thanks .

发自我的 iPhone
Reply all
Reply to author
Forward
0 new messages