Searching \ for '[SX] Capture/Compare on the SX-28' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/devices.htm?key=sx
Search entire site for: 'Capture/Compare on the SX-28'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Capture/Compare on the SX-28'
2006\02\13@021814 by George Herzogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, George Herzog wrote:

I believe this can be done purely in software [a Virtual Perpheral], but I am wondering if an ISR is required or special I/O pins [such as Port B's edge detection]

Primarity I am trying to have 4 PWM signals captured in a series and stored as values to be recalculated and mixed.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\13@041804 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

What is the PWM rate ? How accurate does the measurement have to be ? Is it R/C PWM ?
Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109163
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\13@043911 by George Herzogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, George Herzog wrote:

Hi Bean,
Well, it is r/c PWM, which is roughly a 20 microsecond pulse, but wanders.  And the ON cycle is between 1 and 2 microseconds or according to Guenther's text it may only need to be between 1.3 and 1.7 microseconds.

From what I understand you don't need to measure the width of the whole pulse, merely the width of the on time.  How accurately?  Is 1% asking too much?  Obviously, the rougher the measurement, the easier it is to do, but I am unsure of how rough is useful.   1/256 of 2 microseconds would require one byte; 1/16th would require one nibble.  I suspect those the most convienent choices as I would be counting in a File Register.

I suppose that given those parameters, all I have to do is poll and increment the four inputs rather than actually to a capture/compare emulation.  As I understand it, the R/C reciever outputs the pulses in series [one after another] and if I know the sequence I can start with the #1 in an ISR and move immediately on to #2 after #1 shuts down.  .

Alternatively, I may be wrong and all the Pulses are arriving concurrently.  This would require a different strategy.

This is an old challange as I was trying to write an Assembly language equivalent of the SAMs Autopilot and the jump from C to Assembly for this is a bit unclear.

You discussion of Timers revived my interest.

Still I wonder if capture/compare happen to be something that Virtual Periphercal can or cannot do.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109164
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\13@045154 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

[Quoting: "Kramer"]
Hi Bean,
Well, it is r/c PWM, which is roughly a 20 microsecond pulse, but wanders. And the ON cycle is between 1 and 2 microseconds or according to Guenther's text it may only need to be between 1.3 and 1.7 microseconds.
Kramer,
 Do you mean milliseconds ? That would be much more do-able.

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109166
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\13@051519 by George Herzogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, George Herzog wrote:

Well, i guess I got my milliseconds and microseconds mixed.  Yes...
I've always thought your timimg is better than mine.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109167
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\13@073013 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

Unless you really need a VP, you could just use PULSIN, it will timeout during the long 20ms "reset" time and PULSIN will return 0.

Something along the lines of:

' Wait for reset
DO
 PULSIN pin, 1, x
LOOP UNTIL x = 0
' Read next 4 pulses
cnt = 0
DO
 PULSIN pin, 1, x
 IF x > 0 THEN
   values(cnt) = x
   INC x
 ENDIF
LOOP UNTIL cnt > 3
Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109183
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\13@105049 by Coriolisn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Coriolis wrote:

If you want to offload the software overhead by using the onboard timer functions, you should use the PWM mode of the timers. This permits you to set you base period (frequency) using R2, which resets the timer and sets the output low. By setting R1 to a value between 0 and R2, you set the duty cycle of the PWM.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109218
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\13@234117 by George Herzogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, George Herzog wrote:

Sorry guys, but I would really prefer NOT to use SX/B.  It just makes me have to take a step back in order to learn more SASM.  From what I have read a VP does not have to be in an ISR, it just has to replace a hardware function with a software function.

And, I really don't want to use an SX-48 or SX-52 [with their timers] as this has already been designed and built in an SX-28.  But it was coded with ByteCraft C.

Nonetheless, I will take a look at the SX/B.  It seems nobody has a simple explanation for inputing R/C.  I did Google quite a bit.

As I also said, I have 4 inputs and I don't have a scope so I am not sure if they are simultaneous or sequential.  But it would seem that the SX-48/52 would only allow 2 inputs without using a VP.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109345
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\14@034245 by danieln/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, daniel wrote:

[Quoting: "Kramer"]
It seems nobody has a simple explanation for inputing R/C. I did Google quite a bit.

Did you run across Larry Barello or Bob Blick's 2-channel to H-Bridge mixers?


Barello has a assembler project that describes mixing 2-channel RC input channels into an H-bridge (http://barello.net/Papers/RCtoPWM/index.htm) and a C/Assembler project that exercises 4 RC channels via a joystick (http://barello.net/Papers/ServoPulseGenerator/index.htm). He seems to use the AVR microprocessor in C and Assembly, but translation shouldn't bee all that difficult.  As far as resolution of the PWM pulse, Barello seems to achieve 1 microsecond.


Blick has a project note for a dual channel PWM to H-Bridge written in C (http://www.bobblick.com/techref/projects/sv2hb/sv2hb.html).  

In each project, you may have to read both the description and code to get a clear picture of the R/C input.


Daniel
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109361
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\14@043413 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

Sorry Kramer,
 I thought you wanted to read the PWM pulse train that actually gets transmitted & received. This has all the channels in one signal.
Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109362
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\14@081155 by George Herzogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, George Herzog wrote:

All is forgiven, but alas I am getting nowhere.

Daniel, I am trying to move a C program into SASM, so a C project doesn't help much.

Of course you say that Barello has an Assembler file, but it isn't for an SX - it is an Amtel product [which has a different Capture/compare setup].

Bob Blick seems a bit closer to home [with a PIC], but again I see a hardware capture/compare setup.

Bean, From what I understand that combined channel is not truly PWM.  It is an FM [frequency modulated] Pulse.  I would have to acutally have to capture in more detail.  It is an interesting project, but I would have to receive, demodulate, and so on.

Time for me to just think in through.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109384
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\14@092619 by danieln/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, daniel wrote:

Why not just use an off-the-shelf R/C receiver connects its several output channels to the SX input pins?  Are you desiging the radio receiver into your project?  

Have you seen the following:


http://entertainment.howstuffworks.com/rc-toy.htm shows how a cheap R/C toy's radio stream is constructed.  This is R/C in the only sense of remote control, limited control functions; it seems to use a nonstandard radio stream.


Ron Jesme has posted a ultra-ligh-weight standard R/C receiver project at http://www.tcrobots.org/members/rjesm.htm (about halfway down the page to Micro Receiver.  The linked article (http://tcrobots.org/articles/a05.htm) goes into some detail of his reverse engineering the R/C radio signal and its breakdown into channel control.


Perhaps I misunderstood, though.


If the situation warrents, post the C and we might be able to help you with the SX implementation.




Daniel
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109390
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\14@115546 by danieln/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, daniel wrote:

At the risk of showing my complete ignorance of what was being asked, I'll mention that Jon Williams posted this link--http://www.mh.ttu.ee/risto/rc/electronics/radio/signal.htm--in another thread on this forum (http://forums.parallax.com/forums/default.aspx?f=7&m=106994).  
Additional articles are referenced at the end of the document.  The linked document describes the R/C radio signal rather completely, and seems to confirm Jesme's view of the same.


Daniel
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109416
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\14@174034 by amillern/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, amiller wrote:

The sx-creeper has SX code for a 6 input R/C virtual peripheral.  Just  what you need.

It is well modularized, and should be easy to lift and reuse.

-AGM-
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109461
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\14@224759 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Hi Kramer;
The SX28 really only has the RTCC as a timer, and your challenge is best handled with an ISR.

I have attached some assembler code using an 8 channel state machine to determine the low duration of 8 sequential pulses from an RC receiver.

Because there is some inconsistency in the "end of sequence" determination among receivers, I'll leave it to yourself to figure that part out.

My implementation is meant as a tutorial; it is by no means the best way to do things. Use of subroutines would substantially shorten the code, but would cloud the operation of the state machine somewhat.

I have compiled, but NOT yet run this code as that is not convenient time just now, so it may still have some bugs.

Hope you can learn from it.

Cheers,
Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109475
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\15@000408 by George Herzogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, George Herzog wrote:

Thanks Peter [pjv],
I took a look at your contest code and your style of notation is quite clear - very enjoyable to read.

I spent some time today reviewing what I think it would take and an ISR is definetly part of it.  
I have to capture the beginning and the end of each pulse just to get started, then I have to get the difference.  
If I cannot restart the timer for each pulse, I have to trap values when the counter rolls over and do a special routine.

Then having done that, repeat the process 4 times.  And the cycle repeats approxiably every 20 millaseconds [that creates another programing detail to work out].

I don't have a scope and I think I would need 4 inputs anyway [which is too expensive for me].  So I am just hoping that Jen's Autopilot article is right and the 4 pulses come one after another if you keep the inputs straight.

Everyone else seems to want to drag me off the topic in RF electronics [away from digital] or into switching to C programing in another piece of hardware.  Thanks for the effort, but I am interested in doing this in the SX and SASM and in software.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109481
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\15@113811 by amillern/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, amiller wrote:

Think of your problem in a different way....

1) Let the virtual peripherals work in the background via the ISR, constantly updating registers with the most recent R/C input values.

2) The main code loops, pulling the input values from the virtual peripheral's registers and acting on those values. Using the most recent data to update the ouputs.

No need to worry about the 20ms timing, nor the order of the input channel pulses.

This is the beauty of the SX's speed, and of the transparency of a well crafted virtual peripheral.  Your big timnig/programming concerns are simplified into several smaller/easier tasks.  
Even better, once you create a virtual peripheral to read a particular input, or to send a  particular output, you can reuse that code in project after project, no long piece of linear code that is application specific, no counting of assembler instructions to get the timing tweaked just right, no wasted time rewriting code for problems you've already solved.

-AGM-
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109568
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\15@142920 by lordsteven/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, lordsteve wrote:

Kramer,
Use port B.  Set the 4 pins you need to interrupt on the first edge you want.  When an edge-detect interrupt fires off, change the direction of the edge detect for the pin that caused the interrupt.  When the second interrupt for that pin fires, record the time difference between the two.  You can use prescalers to scale the resolution of RTCC so that 255 fits over your maximum pulse width.  Or you could have a timer interrupt.


Is this at all what we're talking about?

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109614
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\16@022926 by George Herzogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, George Herzog wrote:

Thanks.
I am learning a lot about how to collaborate and how to sort through different peoples approaches to writing SASM.

I too thought that I should use Port B, but I checked the AS BUILT board and it uses Port A.

Andrew came through with the most appropriate code.
 
30 pages of code!  For one chip.

The actual useful information comes out at one and one-half pages.

So I am moving ahead.

I suspect that if my ISR is fast enough, I can afford to miss the edge detection.  Of course it means that I don't have the interupt either.   Do I really need another interupt?  I suspect not this one as it might upset the timing.

Andrew seems to think 127 pulses is adequate, so I have a lot of room for moving the timing around in code.  
One of the problems with using the edge detecting is that I have to 'waste' a couple of steps of code to switch direction.  So why bother?  And it does limit me to Port B.

There are lots of ways to do this that are wasteful and I certainly have thought of my share.  
Andrew simply has a Register assigned to each Input Pin and it is incremented when that Pin is High.  Each pin is polled at a rate that is roughly 2ms/127.  
Since there is a 2ms pulse with roughly a 18ms no pulse [could be much shorter] on one channel, you just immediately process the data for all ports after the last channel shuts down.

With front-to-back reception of 8 channels [8x2ms max] You still have about 4ms to do so under the worst case with 8 channels .

In sum, I seem to be getting some very compact, simple code that can easily handle a full 8 channels of R/C PWM inputs.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109699
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\16@134216 by amillern/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, amiller wrote:

GH,
Quit worrying about the order of the input pulses!!! Quit worrying about 20mS timing!!!  :)  
The R/C Input ISR code keeps a counter of all the input pulse lengths. When a pulse ends, the ISR checks if that pulse length was in range (1ms-2ms). If that pulse width is in range the ISR moves that counter into the result register.  Your main loop code should only look at the result registers, not at the counters.

There is no need for the main loop to wait for all/any of the pulses.  The result registers will always have the latest/last valid signal values received. The main code can continuously loop using/re-using these constantly updating values.  If your main loop is faster/slower than 200mS, no problem.

(The only timing to be concerned with is the 1/128mS timing of the ISR, which you set with retiw, CPU speed, and maybe an ISR multiplexer.)
The values in the result registers are 7-bit, shifted to 8-bits. That is still better than 0.5degree of resolution for your +/-30degree transmitter stick.

-AGM-
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109785
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\02\17@002654 by George Herzogn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, George Herzog wrote:

Thank you Andrew.
I do understand now.

It appears the whole concept of 'capture/compare' is not needed in this case.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=109161#m109874
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2006 , 2007 only
- Today
- New search...