ATmega communication with FS100A

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

Firstly: Welcome!

 

I was hoping I can handle this project by my own, but U'm stuck for too long now.

 

I need to send a trigger signal to HC-SR04 ultrasonic sensor via radio with FS100A at a distance of 30-300cm.

 

I intend to use two ATmega328P. I know, that FS100A is not a great idea, but I'm not really able to quickly buy something else now. Also I believe that it will work on such a short range.

 

I'm working in Eclipse, I've got the very basics like writing a simple program and sending it to AVR covered.

 

In every solution I've found that would fit my situation people use manchester.h library.

 

https://www.instructables.com/id...

 

I've downloaded and added it to the project. I've tried adding them to the most simple code:

 

#include <avr/io.h>
#include <util/delay.h>
#include <Manchester.h>

 

int main(void) {
    //Set the Data Direction Register to output
    DDRB |= (1<<PB1);
    while (1) {
        //Set the signal to vary
        PORTB ^= (1<<PB1);
        //wait 0.5 sec
        _delay_ms(1000);
    }
}

 

But compiler returned an error:

fatal error: WProgram.h: No such file or directory

 

Quick google, added Arduino library and installed arduino platform. Also  #include <Arduino.h> at the beggining of the code. But then:

fatal error: pins_arduino.h: No such file or directory

 

That's where I'm out.

 

Please tell me either how to make this manchester library to work or if there are any pure C libraries that I could use?

 

Also, just to be sure, I will be able to do both this AND send data to putty on computer using UART? Or can I get those seperated somehow?

"Better" is the enemy of "good".

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

I've imported mentioned manchester library into Arduino IDE and compiled provided rx and tx examples without any problems.

Selected board was "Arduino Duemilanove or Diecimila" and selected processor was ATmega328P. 

 

I'm working in Eclipse, I've got the very basics like writing a simple program and sending it to AVR covered.

My suggestion to you is to use Arduino IDE for your project unless you have a reason to not use it.

You can modify the tx and rx examples to suit your needs.

 

Tom

signature

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

If moving to Arduino, check out "Radio Head" library.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

I'm not sure I follow. I don't have arduino, only Atmega328P, without even a bootloader on it, not to mention a board. I don't want to go full Arduino, since I've heard about a number of limitations that it would put on me. However, I do wish to know if and how can I use Arduino based libraries, such as mentioned manchester.

 

Tomorrow I will a few things based on tomcan advice and I'll let you know about the results.

"Better" is the enemy of "good".

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

Welcome to AVRFreaks.

 

With such a short distance of 30 to 300 cms (3 metres), why must you use radio? What is in between your transmitter and receiver?

Ross McKenzie ValuSoft Melbourne Australia

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

You don’t need an arduino board. The Arduino uno has a mega328. You don’t need to bootloader - that is for convenience. You can use the Arduino tools to build your code and generate a hex file. As for ‘limitations’, that’s most likely comments from an uninformed person.
So, to reach your goal, just load the Arduino tools, select uno for the board and build the example code for manchester. Burn the hex file into your mega328. Job done. Verify the operation then make your own mods.
Arduino uses avr-gcc, so whatever works for that will work with Arduino.

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

valusoft there won't be any obstacle in between tranciever and receiver, but it must be wireless. I couldn't think of anything else than this, or 2.4GHz radio (so called Wi-Fi ;) ) or Bluetooth. Both seemed to be more difficult to implement on AVR, and in both cases parts were significantly more expensive.

Kartman thanks a lot for the explaination, it's very helpful. However on other forum someone else told me about pure C libraries, so that's probably the way I'll go for now. That being said I probably will take a shot with Arduino sooner or later and it's so great to have a backup plan

Thanks to all of you for your help!

"Better" is the enemy of "good".

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

Irrehaare wrote:

However on other forum someone else told me about pure C libraries, so that's probably the way I'll go for now.

 

There's nothing wrong with 'pure C'; it's just that you will have to write all the code yourself. Or at the very least you will have to learn what an Arduino hides from you and rewrite that and the Arduino code. 

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

Irrehaare wrote:
there won't be any obstacle in between tranciever and receiver, but it must be wireless
Why? A hard-wired connection would be so must easier and cheaper.

 

Ross McKenzie ValuSoft Melbourne Australia

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

valusoft wrote:

Irrehaare wrote:
there won't be any obstacle in between tranciever and receiver, but it must be wireless
Why? A hard-wired connection would be so must easier and cheaper.

 

 

The project is to detect and locate a remote tranceiver with intention of implementing it to a following robot later on. A don't really wont this robot to need a 3m retracting cable leash. Additionally, a hardware complexity of such leash would nullify gains from software simplification.

"Better" is the enemy of "good".

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

Your comments don’t stand the light of day. Just adding the word ‘Arduino’ seems to invoke some form of mysticism. Many of the libraries are written in ‘pure’ C - whatever that is. How is using, say, he arduino wire functions for i2c any different to using someone else’s i2c functions or ones you wrote yourself? If these functions call other functions to abstract ,say, the I/o, how is this less ‘pure’?

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

As long as it's written in C I'll be happy to add a hypothetic library to my current project, but the essential information in this thread is that Manchester example isn't: it's at some point based on C++.

 

For now in this project I only wish to avoid creating Arduino project, either in Eclipse or Arduino IDE as this means switching languages from C to C++. While this is not something that I've got time to do now, I'll be happy to try it some other day.

 

Although I have to admit, after being reluctant at the begining I've started to enjoy writing in lowly C, shifting registers and so on. It's also easy to take things straight from the AVR documentation from time to time.

 

I've never meant to say that Arduino is somewhat a worse thing.

 

As for now I'm going back to my project, I'll be back here in about ~10h

 

And once again, thank you all for help! It's feels wonderfull to have a support as an amateur!

"Better" is the enemy of "good".

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

So... is this a school project?

Ross McKenzie ValuSoft Melbourne Australia

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

with intention of implementing it to a following robot later on.

Small world.

 

As luck would have it I happen to suddenly have found myself doing the hardware for a simple line following robot based on an Arduino Nano board, and a cheap chassis from the web.  Another individual will be working on the software to make it run.  It is for a school competition.  

 

The rules say the bot can upload data for analysis, but must run autonomously, i.e., it can't receive any guidance from a separate computer.

 

The exception is a simple On/Off - Start/Stop RF link, if desired.  One can turn the bot on, set it on the line, and then use the RF link to turn the bot on.

 

I wanted to keep this project simple, software wise, so I elected not to use the little cheap 433 RF modules.

I've used them before, very successfully, without Manchester encoding, but I used short data packets, warm up characters, a start of packet character, the data load, and a check sum to make them work.

 

For this current project I ordered the cheap Bot chassis from Banggood Electronics, and they also had a cheap Key Fob RF remote, with 4 push buttons, for $3 or $4 each.  The receiver has a data good signal, and four data output pins to indicate which button was pressed.  Trivial to implement, cheap, and certainly less software intensive than writing one's own Manchester encode/decode routines, or even the packet parser for the above alternative option.

 

Good luck with your bot!

 

JC 

 

Edit:

Breadboard with the Prototype, two LEDs simulating the motors.

The RF Key Fob showed up yesterday!

JC

 

 

 

Last Edited: Sun. Feb 10, 2019 - 10:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a FS1000A too, if timing or signal stability is an issue, you better take IR-Leds if you have. Mine wasnt very good at 50cm ! Maybe it is a tuning issue. But i tried also different antennas and nothing really worked really.

Yes i use Google, but there is no search enginge within Google to search through those many useless results...

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

To use the Arduino system you need to download and install the Arduino IDE on your PC.   The IDE [integrated development environment] has all the background files needed, such as pins_arduino.h.

 

But the problem isn't using Arduino: it's using junk libraries from GitHub.  Junk libraries are those that don't have enough documentation or low-level example programs so that people how don't have PhDs in Atmel AVR can get really simple demo programs working without having to read and master a 300-page professional engineering IC data sheet or calling on their 10-years of engineering level experience with complex computer compilers.

 

The code shows nothing more than a pin toggling at 1Hz.  There is a main() function, which means that the code is not in Arduino format, which would be using setup() and  loop() functions instead of main().  However the downloaded libraries are written for Arduino.

 

I suggest that you abandon using Atmel Studio and use the Arduino IDE only.  Buy two Arduino Nano module boards from eBay/aliBaba for $6 and then download any code that you can find for using the FS100A to transmit tiny amounts of data small distances (30-300cm).   Manchester encoding is for semi-reliable transmission/reception of lots of error-free code packets using flaky simple radio-control systems.  You only need to send one bit every half second.  You don't need the hassle of Manchester encoding or Atmel Studio.

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

Those 433Mhz RF units IMO suck.  If you do a search on these units the threads a re long, and frustrations are high.  Bluetooth modules are an inexpensive and simple solution.  A more expensive solution would be to use DIGI modules, but the implementation of them is pretty simple.  Right out of the box you connect them to the USART pins and thats pretty much it.  Outdoors you can easily get 80+ feet out of them.  LINX is another option as well.

 

JIm

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

 

"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 user

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

Ok, time to reply:

@valusoft: that a part of private hobby thing, but I'm writing my engineering thesis about it. As for now I just want to locate a tranceiver precisely enough, with intention of making a robot that would follow it later. It's not very ambitious to other students, that are doing stuff like Cubli reattempt or BB-8.

 

@DocJC nice! I wish I could make it so simple for myself, but because of the reasons above anything that ready is a no-go as too unproffesional.

 

@jgmdesign I probably will switch in the end, but to NRF24L01, since they have much better opinion and more support. Using SPI is a nice bonus for me, I can easily seperate sending to PC with UART and to tranceiver with SIP.

"Better" is the enemy of "good".

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

Irrehaare wrote:
@jgmdesign I probably will switch in the end, but to NRF24L01, since they have much better opinion and more support. Using SPI is a nice bonus for me, I can easily seperate sending to PC with UART and to tranceiver with SIP.

 

I would agree that if you intend to communicate with a PC AND the robot using the M328 then you are on the right track.

 

BUT..........

 

If you want to make your life easy(I know I do) then look at the Mega 324.  It has 2 USARTs

 

Just food for future thought. :)

 

JIm

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

 

"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 user