I need two RX and two TX pin in my program.
In arduino with "SoftwareSerial" easily I can make several RX and TX.
how to make it in avr(make two rx and two tx port)?¿?
Two ways for you:
Add #include path for g++ (must be c++ since Serial is a class).
Then just include the header as you did in Arduino.
Refer to AVR306 and device datasheet (I don't know what your MCU is) to learn how to use USART.
The first is easier and more convenient while the second is more flexible.
I would recommend including the Arduino libraries and just including SoftwareSerial as a one of your libraries because the pins_arduino.h file will take care of the mapping for you. However if you don't have the right pins_arduino.h for your AVR I would recommend looking into this git I made for this issue. I adjusted a lot of the code from SoftwareSerial.
https://github.com/joshagirgis/AVRonly-adjustedRecieveOnlySoftwareSerial
My issue was I wanted to use an atmega644pa with a software serial port but only receive the data. Note: it is much harder to read the data, software serially, than send it (bit banging). I had it receive only because I only needed to read commands from a GPS. The pin must be an interrupt pin.
Related
I am using ESP8266 (NODEMCU 3.0 or something) to make a quadcopter. Ive connected ardu pro mini to RC receiver so I am reading PPM values from it. Pro mini sends data with tx to ESP8266. ESP reads it with software serial with 115200 baudrate. I am communicating with MPU9255 (Waveshire) via I2C either.
My problem is that I cant fully controll my brushless motors. When I was using arduino instead of ESP8266, servo library was the best and reliable. But ESP's servo library is different, since its not AVR, and problems occurs. First of the servo library didnt want to work on most frequencies. I mean default is 50Hz (20000uS) and in this state ESC of motors did armed but unfortunatelly when changes was fast and short (1250-> 1370 -> 1250) it did miss that change like nothing happnd... This makes my D value in PID controller useless...
Sometimes on 100Hz freq all was working fine, but sometimes not...
When Ive started to use analogWrite only 500Hz was working fine, rest of freq didnt want to arm ESCs.
PS. I am using 3.3V to 5V converter for PPM/PWM pins so I am sure that the signal is fine for ESCs.
PS2. I dont have any osciloscope unfortunately.
The ESP82266 present on your module is a RF transceiver integrated circuit that can handle WiFi communication, both configured as a slave to a microcontroller such as the ones present on various Arduino boards, or as a standalone chip by having it's on-board Tensilica L106 32-bit processor programmed via an external SPI flash memory. If used as a slave, the communication between, for example, an Arduino an the ESP82266 can be done using different protocols such as SPI / SDIO or I2C / UART interfaces. Googling a comprehensive Tensilica L106 user guide on the internet doesn't seem an easy task, and it looks as if some people have already failed to find it. If you're seeking to add Wi-Fi capabilities to your quadcopter the solution I suggest is having the Arduino take control over the servos, motors, etc. and hand off messages via SPI to your ESP82266 module. If this isn't the answer you are looking for, please try to be clearer about it, maybe find someone to do as an English translator for you.
However, if this is what you're concerned about, and you would like to use the ESP82266 module as as standalone solution, please link its built-in processor datasheet and the relevant parts of the quadcopters code that might need debugging.
I am using an ATtiny85 8 pin AVR to send AT commands to an RN42 Bluetooth module. I am programming the AVR using an Arduino as an ISP therefore writing the code in the Arduino IDE, using the SoftwareSerial library as the AVR has no UART port.
To ensure accurate clocking out of the data I have added an 8MHz oscillator (LFSPXO018045) on pin 2 but I'm not sure how to make sure the AVR is using this and not just defaulting to the internal osc. I've seen mention of "Fuses" that need setting? Is there any in-code things I need to do like set a register flag or any pre-scalers?
Here is the Eagle circuit and option I found so far but don't know if there's anything else that needs doing too?: PCB & IDE
By the way this is my first question so please be lenient if I've missed something!
Clock settings of AVR MCUs can be changed via using the dedicated Fuse bits. These Fuse bits unfortunately cannot be modified from software. The only way to program the Fuse bits is either using a JTAG programmer or an ISP programmer (like: USBasp, AVRISP mkII or you can use an Arduino as an ISP programmer with the right sketch on it).
This AVR Fuse calculator tool can be used to determine what settings and Fuse values you need to program.
I would like to use the Arduino sensor in raspberry pi.
Since the sample file for the sensor is dedicated to the Arduino, the example header file is also dedicated to Arduino.
The example code uses the spi.h file. Can I download the header file and use it in Raspberry Pi?
That wouldn't make sense for various reasons and it wouldn't work for various reasons.
SPI is a serial interface. You don't need Arudino code to communicate via SPI on Raspberry PI. There are many examples on how to do that on Raspberry PI.
The sensor doesn't need an arduino. All it needs is power and someone to talk to.
The fact that you ask this question shows that you should invest time into learning C/C++ and get some basic knowledge about microcontrollers and serial interfaces.
If you're lost in an unknown jungle it won't help you to bring a map from another unknown jungle... So what do you have to do? Learn about jungles in general and some day you'll be able to survive in most of them.
Is it possible to run a serial port (soft or hardware) that only reads? The examples I see all involve two pins for read and write. I would like to use the TX pin for something else.
Here is a version of the SoftwareSerial library with the TX parts gone:
https://github.com/jbeuckm/SoftwareSerialIn
I want to use ATmega2560 MC, but it manufactured only as surface mount IC which means i must make PCB to use it. I searched for a per-made kit and found Arduino Mega R3 board contains the desired MC. (It contains less I/O pins but that's OK for now). Can i implement my code (without any arduino code) in this board? or should i modify it to work with Arduino, also if it runs in the board will it be the same as normal IC or there will be differences in speed.
The MCU in the Arduino Mega2560 is a stock ATmega2560. There is no need to use the Arduino libraries to program it and no need to use the Arduino tools to communicate with it; avr-gcc and avrdude will work with it as normal. Note that you will need to select the appropriate programmer/protocol in avrdude for the bootloader programmed on the chip if you want to program it via serial rather than ISP.