Giter Site home page Giter Site logo

Atmega2560 pins about msrc HOT 56 CLOSED

dgatf avatar dgatf commented on July 17, 2024
Atmega2560 pins

from msrc.

Comments (56)

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Found the pin mapping I guess
https://robotdyn.com/pub/media/0G-00005642==MEGA-PROMINI-ATmega2560/DOCS/PINOUT==0G-00005642==MEGA-PROMINI-ATmega2560.pdf

from msrc.

dgatf avatar dgatf commented on July 17, 2024

I've improved the pin table with usual pin numbers

ATmega250 pinout

Which rx protocol are you using? smartport, xbus, srxl?

Are you attaching a esc serial or castle?

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

I am using a Radiomaster R161. Smart port wire and VCC and GND go to the Mega2560 pin VCC/GND and D4/D12 with pullup). S.Bus + VCC and GND go to FBL
msrc.lua does not detect the board and no sensors are detected. Was working with 328P pro micro before. Are ports D4 and D12 (4 and 12) the correct ones for smartport?

from msrc.

dgatf avatar dgatf commented on July 17, 2024

There was an error on the readme. Fixed. Correct pins for ATmega2560 are 10 and 15

castle_atmega2560_smartport_2

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Thanks, will try it out

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Indeed, much better now :-)

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Is it correct that BN-220 GPS TX goes to pin D17 on Mega2560? I do get a GPS signal (VCC is connected to 5V and GND to GND) but the coordinates are garbage as are the other GPS values. Same applies for BMP280 ALT value

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Yes, D17 is the correct pin for GPS. Be sure you have set the default baud rate 9600

I'll check GPS and BMP280 for ATmega2560 in the following days

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Yes, D17 is the correct pin for GPS. Be sure you have set the default baud rate 9600

I'll check GPS and BMP280 for ATmega2560 in the following days

Do I have to set baudrate in your code somewhere?

from msrc.

dgatf avatar dgatf commented on July 17, 2024

If you are using other baud rate than the default 9600 in BN220 you can change its baud rate (with ucenter app from ublox) or you can change line 450 in smartport.cpp

GPS_SERIAL.begin(9600);

with the desired baud rate

Edit: added GPS_BAUD_RATE to config.h, line 23. You can adjust the GPS baud rate in config.h

from msrc.

dgatf avatar dgatf commented on July 17, 2024

To debug the gps, download latest code as debug for gps was broken

Enable gps debug in config.h, line 119:

#define DEBUG_GPS

and post the output (with serial monitor at 115200)

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Please download latest code: now all gps values are initialized to 0 so you won't get garbage values if there is no data input from the gps

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Same applies for BMP280. You were getting garbage values because BMP280 is not communicating with Arduino

Now I've updated the code so altitude will be 0 even if there is no data input from BMP280. Note that the default I2C address for BMP280 is 0x77, but also can be 0x76

Download latest code and review connections and config

from msrc.

dgatf avatar dgatf commented on July 17, 2024

For BMP280 there was an issue with the altitude calculation. Fixed

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Date/time and lat/log values were twisted. Fixed
Also altitude is now limited to values bigger than 0

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

GPS looks OK now, still 0m with BMP280 (address 76 since pin determining address is not connected to anything)
I'll continue investigating

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Do you get a valid value for bmp280 temperature at sensor Tmp1 (0x401)?

Altitude is 0m at ground

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

temp is 0 deg
alt = 0m

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Seems BMP is not working. Connection is straaight forward if SCL and SDA pins are corresponding in schema vs code

from msrc.

dgatf avatar dgatf commented on July 17, 2024

If you are using lua for config, i2c address is in decimal, 0x76 is 118 and 0x77 is 119

And connect BMP_Vcc to 3.3v and BMP_GND to GND

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Hmm, address might be wrong indeed

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Since the last commit I do notice when clicking update in LUA, UPDATING takes forever. Wi have to stop it with ret key on TX. When restarting msrc.lua, values are retained.

from msrc.

dgatf avatar dgatf commented on July 17, 2024

There was a bug in the lua script that was causing wrong I2C config. Please upload the latest lua script to the radio, update config and check if BMP is working

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Since the last commit I do notice when clicking update in LUA, UPDATING takes forever. Wi have to stop it with ret key on TX. When restarting msrc.lua, values are retained.

Fixed. Please flash latest code

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Updating still keeps flashing. I have to quit it with return.
Alt and Tmp1 remains 0.
Awaiting new sensor module which should arrive any day now. Will swap module to try this option.

from msrc.

dgatf avatar dgatf commented on July 17, 2024
  1. Could you flash the latest code and enable in config.h:
#define DEBUG_EEPROM_WRITE
#define DEBUG_EEPROM_READ

And post the result when booting and also when updating from lua

  1. Disable the previous and enable #define DEBUG and post the output when updating from lua

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Sorry, now is updated for debug

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Can I connect both the S.Port connector and the usb connector to the Mega2560 board at the same time to output the debug? Won't overload board nor PC USB Port? Just to be sure

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Disconnect Vcc from smartport, keep only GND and data lines

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024
1. Could you flash the latest code and enable in _config.h_:
#define DEBUG_EEPROM_WRITE
#define DEBUG_EEPROM_READ

Gives
V0.8.0 RC Pr:4 As:0 Gp:1 V1:1 V2:0 Cu:1 T1:0 T2:0 Po:1 rR:10 rV:10 rC:10 rT:10 aR:3 aV:3 aC:3 aT:3 I1:1 A1:118 I2:2 A2:0 RC Pr:4 As:0 Gp:1 V1:1 V2:0 Cu:1 T1:0 T2:0 Po:1 rR:10 rV:10 rC:10 rT:10 aR:3 aV:3 aC:3 aT:3 I1:1 A1:118 I2:2 A2:0 9⸮&⸮$⸮⸮⸮�ą⸮⸮R⸮⸮⸮vq⸮⸮�M'⸮)t6�⸮H⸮ɉ�⸮⸮⸮⸮⸮⸮ V0.8.0 RC Pr:4 As:0 Gp:1 V1:1 V2:0 Cu:1 T1:0 T2:0 Po:1 rR:10 rV:10 rC:10 rT:10 aR:3 aV:3 aC:3 aT:3 I1:1 A1:118 I2:2 A2:0 RC Pr:4 As:0 Gp:1 V1:1 V2:0 Cu:1 T1:0 T2:0 Po:1 rR:10 rV:10 rC:10 rT:10 aR:3 aV:3 aC:3 aT:3 I1:1 A1:118 I2:2 A2:0

And post the result when booting and also when updating from lua

1. Disable the previous and enable `#define DEBUG` and post the output when updating from lua

gives a lot, but when clicking update I get
M+ <F:31 D:5000 V:AAAA96F1 <F:31 D:5000 V:43333F2 <F:31 D:5000 V0.8.0
after that it remains UPDATING and no further debug output

from msrc.

dgatf avatar dgatf commented on July 17, 2024

I2C config seems good (I1:1 A1:118). You could try with address 119 (0x77), just in case

The arduino is rebooting when updating from lua. That's why lua keeps trying to update

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Fixed the updating forever issue with lua. There was an issue deleting objects

Please try latest code

from msrc.

dgatf avatar dgatf commented on July 17, 2024

I've got BMP280 working at 0x76. I recommend to test BMP280 with a specific sketch (that you can find in some arduino libraries). You may need to replace the sensor. Remember to connect BMP Vcc to 3.3v, not 5v

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Thanks, will try with a new sensor. Should arrive in the mailbox any moment now

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

The LUA on the Transmitter works well again.
The BMP280 (a brandnew one) does not give any telemetry data via I2C.
It is connected to
GND - GND
SDA - D20
SCL - D21
3V3 - 3V3

In LUA on TX I sellect I2C1 as BMP280 and address 118/119 (tried both)
TMP1 and ALT remain both 0

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Please flash i2c_scan.ino (in tools folder) to check circuit and BMP module. No need to power the receiver or anything else

In serial monitor at 115200, you should see:

I2C scanner
76
Done

Where 76 is the address in hex. If no number, there is an issue with the circuit or the module

If you see the address, disconnect smartpoft Vcc, flash msrc.ino again enabling debug #define DEBUG and post the output

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Will have to search, BMP is brand new

I2C scanner
Done

D20 - SDA and D21 - SCL are correct right?

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Yes, correct. Be sure they are not interchanged (try interchanging them just un case). Dont use long wires. It looks like a circuit issue

from msrc.

dgatf avatar dgatf commented on July 17, 2024

I see you are using a HW v5 LH ESC. Could you post the ESC signature by enabling #debug DEBUG_ESC_HW_V4
It will appear before raising throttle and the output is S: and some hex values. I'm trying to autodetect the ESC model to adjust sensor transformations
Are you getting correct values for the current?
Thanks

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Actually I use a HW V4 => my config was wrong

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Running out of ideas. Swapped SDA and SCL, same result.
The BMP gets 3,3V
Wires are 7cm

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Do you have another Arduino to test with?

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Could you post a picture or a link to your bmp280 module?

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Your module may be stuck in SPI mode
I've modified the I2C scanner to loop every 3sec
Flash the updated i2c_scan.ino. To select I2C mode, CS pin must be high (3.3v) at startup (connect the pin before power up). I believe you can disconnect the pin after bootup and needs to be done only once

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

There is no CS pin on the module
VCC - GND - SCL - SDA - CS0 and SD0

from msrc.

dgatf avatar dgatf commented on July 17, 2024

CS=CS0

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

CS=CS0
CSB I meant. Tried that one, same result

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Maybe a picture of the circuit you made will help

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

See attached. The yellow wire is going to D20 - SDA and the blue to D21 - SCL
VCC to 3.3V and GND to GND on the Mega2560 board.

20210312_154006
20210312_154013

from msrc.

dgatf avatar dgatf commented on July 17, 2024

Looks ok... don't know what else...

You can try connecting SD0 to GND or 3.3V. This defines the address (0x76, 0x77). With CSB disconnected or to 3.3v

You can try 5V version of BMP280, which is 4 pins and only I2C. Though I'm using the same board as you, 3.3v 6 pins, without any issue

Try with another Arduino

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Can this come into play http://www.varesano.net/blog/fabio/how-disable-internal-arduino-atmega-pullups-sda-and-scl-i2c-bus?
The Mega2560 apparently outputs 5V on its I2C interface while the BMP280 is 3V3 only

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

If the case I probably blew up 2 BMP280-3V3 already :-)
Have 2 BMP280-5V ordered now to test. Will arrive in 6 weeks or so :-p

from msrc.

dgatf avatar dgatf commented on July 17, 2024

It might be. I always used a 3.3v BMP module without issues, but that does not guarantee other modules wont get burnt. Let me know

from msrc.

dgatf avatar dgatf commented on July 17, 2024

As a last resort you can try with external pull up resistors (4~5k) on SDA and SCL lines. See circuit (Keep D20/D21 for I2C on your ATmega2560)

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

In the meantime tested the BMP280-3V3 with an Arduino Pro Mini 3V3 (SDA -> A4 and SCL -> A5). I2CScan gives no address. Probably both modules are dead. Will try with the 5V version as soon it arrives

from msrc.

stefaanbolle avatar stefaanbolle commented on July 17, 2024

Even with a new BMP280-5V I get no output on Tmp and Alt

from msrc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.