Six frequency outputs

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm having a little problem coming up with a reasonable way to complete a circuit. I would like to be able to drive 6 continuous ultrasonic outputs. Each output would range from roughly 22KHz to 40KHz. The outputs need to be individually frequency controllable. For example, output zero would be at 34 KHz and going up at 200KHz per second, output one would be at 29KHz and going down at 100KHz per second, etc. The climbing/falling speed and direction of the outputs would need to be software controllable.

I've looked at using the PWM6 on a processor such at the ATTINY861. But, it appears to be operating the outputs at the same frequency, just modifying the pulse width. I've tried using software to generate the output frequencies on a single ATTINY861. But, I have not been able to get the output frequencies with the resolution I would like to see with only a 20MHz clock and timer1 with an output compare interrupt.

One option is to use 6 ATTINY13's, one for each output. This would work, but I would like to know if anyone has a better / more elegant solution. (Using one IC to generate the frequencies would be nice)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know this is heretical but have you heard of the Propeller chip:

http://www.parallax.com/propeller

Moderators: If this is not allowed please feel free to delete this post.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Building one, or one million?

If you are only building a couple of the units then why not use one processor for each channel?

One master unit sends commands to the 6 remotes on an SPI bus. It can then also read back their individual channel's data.

Once you have the code for one module to receive a packet, (ID, Start Freq, Stop Freq, Rate, Single Sweep / Repeat, Chksum; or whatever, (with many of the values being a table index hence 1 byte)), you suddenly have all 6 units working.

Then you can focus your time on the Master Unit's control code and data processing.

Uncle Bob just got shot down for suggesting a multi-processor solution in the current Engine Control Unit Thread. Me, I like multi-processor projects. Ignore the nay-sayers and get on with the project!

Sounds like an interesting project, can you tell more?

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Doc,

Gosh, I hope you didn't think I was being a naysayer. I am absolutely pro multi-processor especially for a project like this. The above, heretical, example just gives you that in one package. It does have a steep learning curve though.

I think your idea fits matt6ft9's requirements perfectly and agree with your comment about it being an interesting project. I hope he can share it with us.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Larry,

I cross-posted with you, and had not seen your reply when I submitted mine.

I was referring to the ECU Thread folks who didn't like Uncle Bob's multi-processor solution.

And, yes, I think the Propeller would be a good option, essentially putting multiple cores inside one physical chip. I read the Prop column in Nuts & Volts every month, but I've never worked with one.

In my hands a multi-AVR approach would be faster to get up and running as it would avoid the Propeller learning curve. Those who can readily program in 1/2 dozen languages, (or more), could probably learn the Prop language very quickly.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just now read that thread. Bob has been taking a lot of heat lately in my opinion.

I guess I should have looked at your post time. I've tinkered with the Propeller but never did anything complicated with it.

I have a few ATtiny2313V chips laying around, I might try to implement something similar to this project. Lots of time on my hands recently, see my sig.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use ONE Xmega A3 series and you can do up to 7 independent frequencies !

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Each output would range from roughly 22KHz to 40KHz. The outputs need to be individually frequency controllable. For example, output zero would be at 34 KHz and going up at 200KHz per second, output one would be at 29KHz and going down at 100KHz per second, etc. The climbing/falling speed and direction of the outputs would need to be software controllable.

I presume your 200kHz/s rate means 200Hz per millisecond. Otherwise you exceed 40kHz in the first step !

You can do this with all 3 timers of a mega168 or mega164 using pins OC0A,0B,1A,1B,2A,2B.

At each COMPx interrupt, set the OCRnx register for the next value (i.e. the next half-cycle). The hardware toggles the OCnx pins exactly on time. You can have a maximum 12.5us or 250 cycles @ 20MHz. Since a typical :

ISR(TIMER1_COMPA_vect)
{
    OCR1A += output3_period;
}

you are not going to have too much problem with cycles. And Timer0,2 are 8-bit anyway.

Life would certainly be easier with a chip that has more independent timers. Then you would be able to leave everything to hardware.

I suppose at a real pinch, you could use each timer in CTC mode. 3 channels are hardware controlled. This would mean you only need the COMPB interrupts. The 3 'B' channels would calculate the next 'match' value by using the CTC value. When you change the OCRnA values (in the foreground), you must ensure that the corresponding OCRnB value is still valid.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am building just one. It’s for a “dog deterrent” electronic noisemaker that will sit under my bicycle seat. The idea is flip a switch and this box will start generating very loud ultrasonic frequencies near the bicycle. The emitters are rated at 109dB at resonance, but I plan on cycling the frequencies up and down. (Kind of like an ultrasonic wailing siren) I have no idea if it will work. I’m carrying pepper spray as a backup. :)

I’ve heard of the propeller before, but have not looked in it. That might make the project a little more interesting. I’ll also look at the Xmega A3.

Doh. I typo’d. I meant 200Hz / 100Hz.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In which case it won't be very important for complete independence of channels. Nor will the occasional odd length half-cycle.
So you can implement this with pretty well any AVR.

Can't you cycle faster than most dogs can run ?

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I’m making this too complicated. There are going to be three emitters on the left and three on the right. Pairing up the rear emitters, middle emitters, and front emitters is very reasonable. So, only three frequencies are needed.
Absolutely not. It tends to be the younger and in shape dogs that give chase. I’m neither young nor in shape. Most of the time, I have been going for miles and the dog is starting from rest. One time I ran into a greyhound. ‘don’t think I’m going to outrun him.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes. That can give 3 different signals. No interrupts. Nothing complicated.

Just vary OCRnA to alter the CTC frequency. OCRnA between 99 and 180 for F_CPU @ 8MHz. When you alter OCR1A downwards, wait for TCNT1 to be < 50 before you write the new value. (else you could have a long half-period if you rollover from 180 -> 65535 -> 0 -> 179)

No, I can't outpace a greyhound. OTOH, I doubt if a greyhound would attack you. You aren't furry enough!
You should beat a Rottweiller or PitBull. They are the dogs to worry about.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK it can be done as 3 SW DDS's (just use the C flag for the output value)
A 20 clk LOOP give you max freq of 500KHz.
Have a "slow" timer interrupt that update the freq. (it will make a small click but I don't think it will matter for this app :D )