Help with serial communication in atmega328p using assembly

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

I developed a line follower car and the final coding is in this thread.

https://www.avrfreaks.net/forum/developing-line-follower-car-assembly-language-using-atmel-studioatmega328p

 

Now I have to develop this car with a IR receiver to detect a parking spot. A certain device is transmitting a number like "12345678". The car should detect this number. I know this can be achieved by using USART in atmega328p. I have an understanding about what each register does, but I am having hard time developing a program to the above task. I know this is not a good question. I couldn't find any helping assembly codes online. 

 

If someone could help me with a sample code or anything it would mean a lot. Thanks :)

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

What research have you done regarding IR communication? How are you proposing to send and receive the data?
Hint- uart is not a good idea.

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

I did some research but it was tough to understand things on my own. Compared interrupts I find the serial communication part a little harder. So please forgive me for this poorly formed question again. 

 

Our task changed. There would be a parking spot device emitting IR rays (not a number). And the car has to detect the parking spot based on that IR ray and reverse to that parking spot. The only way I can think to do this is using the Rx pin (PD0) in Arduino uno board. I have a three pin IR consumer device. Please educate me on how to approach this. It would mean a lot. If someone could post a sample assembly code that would be great :)

 

Thank you.

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

Kartman wrote:
What research have you done regarding IR communication? 

@esavrperson -  Take a look at this recent thread for some hints:

 

https://www.avrfreaks.net/forum/ir-data-transfer-usart

 

esavrperson wrote:
Our task changed.

So time for a new thread - if this no longer has anything to do with the current subject, "Help with serial communication in atmega328p using assembly"

 

Or, at least, change the title to something relevant to the actual problem.

 

 

There would be a parking spot device emitting IR rays (not a number).

So you mean just a beacon - constantly shining IR light?

 

In that case, Perhaps it would help you to forget, for  moment,  that it's IR - and just think about how you would do this with a visible light beacon...

 

The only way I can think to do this is using the Rx pin (PD0) in Arduino uno board

Why that pin, specifically? How do you see that working?

 

. I have a three pin IR consumer device.

Go on - tell us what device it is?

 

How do you intend to use it?

 

Remember that consumer IR remote control receivers are not designed to be directional - because you don't want it to be critical that the user points it in exactly the right direction at exactly the right spot ...

 

Please educate me on how to approach this

I'm sure it's been mentioned before: you need to think about the basics of how you can detect a light - any light - and how to work out whether you're travelling towards it or not.

 

Don't start thinking about implementation details like processor pins or code until you've worked out these principles

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


esavrperson wrote:
The only way I can think to do this is using the Rx pin (PD0) in Arduino uno board.
if you are going to pick AVR pins totally at random what draws you specifically to RXD? Why not MISO or something? How about INt0? Or PIND.5 ?

 

You can't just say "it's a signal into an AVR therefore it has to go into a reception pin like RX". It makes no sense.

 

You need to start by understanding IR. Generally there's usually something like a 38kHz sub-carrier then data is modulated onto that to pass the actual data bits.

A page like this goes some way to explaining the concept.

 

https://learn.sparkfun.com/tutorials/ir-communication/all

 

It even has pretty pictures like this:

 

 

The sparkfun page borrows some of its info and that diagram from  https://www.sbprojects.net/knowledge/ir/index.php  in fact. It goes on to explain that the "triangle" on the right in this connection diagram is more specifically something like:

 

 

What is coming out of the right hand end of the first diagram is NOT a UART signal so there's no reason why you would necessarily pick RXD as the pin to attach it to. In fact you just need it coming into a pin you can sense the state of. So that could be a polled port pin, or a PCINT or an INTn. They are much more likely to be candidates for this than UART (which expects a rather exact timing and a certain "frame format" to work.

 

Perhaps your "3  pin device" is something like the TSOP382 on that page?

Last Edited: Thu. Oct 31, 2019 - 02:48 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Generally there's usually something like a 38kHz sub-carrier then data is modulated onto that

Indeed. (for IR remote controls).

 

But then I don't understand:

In #3, esavrperson wrote:
device emitting IR rays (not a number)

Does that mean:

 

  • constant, modulated IR illumination?
  • Or just the 38kHz carrier?
  • or what??

 

@esavrperson: you need to clarify!

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Oct 31, 2019 - 02:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am sorry my bad :( This is the task. This was on my college website.

 

 

                  The height of the IR emitter in the parking bay will be 9cm above the ground

    •  The width of the parking bay will be 12 cm.

    • The Emitter will be in the center of the parking bay.

    • The IR emitter will be emitting random data from one of the parking bay, your Robot should be parked in the bay that emits the data(via UART).

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

You really need to go back to your teacher to clarify what, exactly, that means.

 

There are several ways to transmit "data" via IR light - see the thread I linked earlier.

 

You need to understand which one is being used!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

esavrperson wrote:
The IR emitter will be emitting random data from one of the parking bay, your Robot should be parked in the bay that emits the data(via UART).

So how do you sort out this one IR emitter from other (random) IR noise sources? 

I would be asking a LOT more questions of my teacher about this assignment......

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Hello again, I am being honest. This is everything we were told. And there was no possibility to meet the teacher. Truly this was truly frustrating how my college functions. Really ruined the whole experience for me.

But forget that.

 

I am having a hard time understanding serial communication in atmega328p. Can you gentlemen suggest me a good tutorial page to start learning?

Last Edited: Sun. Nov 3, 2019 - 03:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

esavrperson wrote:
I am having a hard time understanding serial communication in atmega328p. 

Do you mean serial communication in general?

 

https://learn.sparkfun.com/tutorials/serial-communication/all

 

Or the specifics of using the ATmega328's UART ?

 

Have you checked-out the Tutorials section of this site?

 

https://www.avrfreaks.net/forums/tutorials

 

Or the documents available on the Product Page:

 

https://www.microchip.com/wwwproducts/en/ATmega328p - see the 'Documents' tab

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

These tutorials will help me sir. Thank you :)

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

Please don't mind me asking, because you haven't told us:

 

Is this a real full-sized licensed car that carries human passengers on a public road?

 

Or is this a small 10 centimeter by 10 centimeter little "model toy car" that is moving on the floor inside of a building?

 

Is a "parking space" simply an area of the floor where the "model toy car" will move to and then stop?

 

Or is a parking space a unoccupied area about 3 meters by 5 meters where a full-sized passenger vehicle is left immobile for a few hours, such as a space in a shopping center mall automobile parking lot?

 

Are you interfacing with per-existing automobile computer systems?  Is this a self-driving automobile test vehicle?  Will this "car" be operating on public roads?

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

Hello :)

 

This is actually like a toy car, Here's a picture. I really have no idea how the parking bays/zones look like. sorry :(