New project - how two synchronize two microcontrollers

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

Hi,

I need to make one project and I would like to share your opinion.
Well whole thing is that I have to read two sinus signals. They should be phase shifted. Their phase difference is 90 degrees. Sinus and cosinus.

I would like to make my project on two atmega8.
But one microcontroller I would like to use as a SIMULATOR and another as an ANALYSER.

Simulator should produce two signals sinus which will be shifted for a 90 degrees from another sinus.
If you push phase buton you change phase from 90 to -90. Via simulator I should also be able to set length of the signal(two pushbuttons). When I switch button "start" buttons should be disactivated.
I think that the best option to do that is to switch off Timer/Counter0 overflow interrupt enable for a while when signals will be genarating. I won`t use signals longer than two or three periods. Freguency of these sirgnals wIll be also low.

Well coming to the main aspect and main my concern.
As I can do this all I don`t know how to coordinate these two microcontrollers. I need to coordinate them cause only one handle display which shows ordered value and shows read value. For example I am pushing button length+ two times and should have 0.5 period of the two signals. But on display I can read 0.25 cause second microcontroller didn`t read button on time.
I don`t know if I expleined it right but the problem is that I cannot use display in simulator cause I used almost all pins.

Well maybe there is option how to read these buttons in one time. This problem really drives me crazy ?
I am using Danni`s debouncing procedure anid as far as I am conce.rn TCCNT0 of these two microcontrollersshould be exactly the same two provides interrupts in the same time. Maybe set one timer via interrupt from another ??

Or maybe use microcontroller with more pins not atmega8 ??

Waiting for your suggestions

I am also enclosing picture of my drawings!

Adam

Attachment(s): 

Last Edited: Tue. May 21, 2019 - 07:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well I've tried but I don't really understand what it is that you percieve to be a problem here. Are you saying that you expect BOTH micros to read the same buttons or something? Usually if you want two micros to "talk" you'd wire them together with a protocol such as SPI or TWI(I2C) with one acting as a "master" and the other as a "slave". Either can send the other one messages to tell it things like "button C was just pressed" but the timing of when such messages pass to and fro is dictated only by the master. Alternatively you could wire the UARTs together and either could invoke a receive interrupt on the other when it felt the need.

But I'm not sure if any of that advice helps because I'm not entirely sure what the "problem" is. Maybe the reason there's been no other replies is because others need further explanation too?

Cliff

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

Thank you Cliff

Yes I was not sure if my message will be uderstood!
It was really hard to describe it.

Cliff wrote:
Are you saying that you expect BOTH micros to read the same buttons or something?

Yes exactly that`s what I want to do.
I don`t think so I will use USART cause I will need it to comunicate with PC.Maybe I will try to implement SPI or TWI(I2C)protocol.
Anyway you showed me the way which I should follow :)
Well in the simulator just one pin left so it will be hard to make them read each other. I think I will buy bigger AVR such as atmega16 and make these two devices separate completly with two displyas. One will be acting as simulator and anothr as an analyser device.

Adam

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

Quote:
I don`t think so I will use USART cause I will need it to comunicate with PC...
...I think I will buy bigger AVR such as atmega16

Try to get ATmega164P instead. You'll get 2 USARTs in each chip along with many other advanced features.

Regards
Sebastian

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

But actually, for inter-CPU I'd just go for SPI - it's so easy to implement and you'd have just one of the chips reading the buttons then, it it were the master, it could immediately report the change in button state to the slave though if it were the slave it'd either have to wait for the master to come along and ask it what the button states currently were or it could use yet another line to an ext-int on the master to signal that it has something to tell the master who'd then instigate an SPI transfer.

Cliff

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

hi dear friend i have the same project now; please send me your code to me; or tell me how you do it

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

alihomayon wrote:

hi dear friend i have the same project now; please send me your code to me; or tell me how you do it

 

Waking up a 12 year old thread as your first post , not nice.

 

/Bingo

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

I am so sorry; but I need help; this project is my university project

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

Suggest you start a new topic, describe your project, show what you have done so far, and tell us where you are stuck.

Also, when is the project due?

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

alihomayon wrote:
I am so sorry; but I need help; this project is my university project

 

And when was this University project assigned, and when is it due?devil

 

Another Jim

 

EDIT:

and STOP harassing other threads with your begging!!

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Tue. May 21, 2019 - 07:19 PM
Topic locked