TX2 RX2... Am I missing something?

zmemw16
Posts: 1295
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: TX2 RX2... Am I missing something?

Post by zmemw16 » Fri Aug 12, 2016 10:34 am

remind me if sending 'Hello' char by char works, each way mm<->avr?
stephen

Nutsy
Posts: 237
Joined: Sun Jul 24, 2016 4:26 pm

Re: TX2 RX2... Am I missing something?

Post by Nutsy » Fri Aug 12, 2016 11:48 am

Wow lots to reply to, ill try to get everything...

edogaldo, I'll try that out and let you know, Im still fairly new to C++ If i was VBAing I would just encapsulate the variables in the type I wanted them to convert to.

Roger, Ill get the new master from github after the weekend, who knows might even speed up fastLED as the new serial would be none blocking.
I completely forgot about software serial being an option, as you probably know theres only 1 serial on this arduino pro mini, It never occurred to me that I could do serial prints with software serial to check the numbers... One of the biggest drawbacks in arduino type building is no real debugging features, I would love to place stops in my code and cycle through line by line to see whats going on and what variables are holding what numbers...
I will also have a go at getting that going a little later too, see whats going on. ill have to get the soldering iron out though to put some connectors on the spare pins. (or i can just build this onto my full sized arduino and just test there... no soldering required :p)

As for scheduler, yeah i realise after learning how to set it up its not too powerful, its really just a timer to say what loop function to call and when. I was hoping for better multi threading than that, IE if its even possible proper staggering of code running... Say a portion of this loop then a portion of that loop and another portion of this loop.......... That would have negated the need for me to setup a second board to just run the motors as everything would have run more smoothly. While this loop scheduler improved things the motors still were noticeably choppy.

As for the whole 8 bit 32 bit stuff... I really am still very new to programming and thats approaching the engineering level that calls for BSE and PHDs in computer science... Which is funnily something I would have liked to have done if life circumstances were different.
And whats an endian? :D

Also, I've been using the AVR Mark2 compiler for all this stuff, is that right? Or should I be using a different compiler?

Pito, yeah I've been messing with types, its mostly down to trying to get things to work trying different things out, I could probably still do with cleaning up the code a little.
But I said before, I realise the RPM shouldn't need to be long as I think int goes -32000 to 32000 or something... As for the int or long on the byte, Thats only there because it was in the tutorial...
I removed all the easy transfer stuff after getting the serial read side half working... I assume as Roger said the formatting of the data being sent between the boards is incompatible.


I just want to thank everyone for taking the time to look through my code. I realise how much a pain in the arse it is to read through other peoples code, esp when its some one at my skill level and badly documented.

Ill try the software serial to get the debug prints working and take another look at my type castings and keep you updated... Its annoying that its soooooo tantalisingly close to having this bit working and me not being able to work out why its not :D

edogaldo
Posts: 252
Joined: Fri Jun 03, 2016 8:19 am

Re: TX2 RX2... Am I missing something?

Post by edogaldo » Fri Aug 12, 2016 12:27 pm

Another suggestion: why not making the Maple process the formulas and just send to the Arduino the results?!

Best, E.

Nutsy
Posts: 237
Joined: Sun Jul 24, 2016 4:26 pm

Re: TX2 RX2... Am I missing something?

Post by Nutsy » Fri Aug 12, 2016 12:33 pm

edogaldo wrote:Another suggestion: why not making the Maple process the formulas and just send to the Arduino the results?!

Best, E.
Ive considered that too, but i felt being fairly simple formulas it wouldn't really tax the ard...

Besides the Maple will have to deal with a lot of real time stuff, IE reading RPM and MPH pulses and working out the speed they go...

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: TX2 RX2... Am I missing something?

Post by madias » Fri Aug 12, 2016 5:45 pm

If you need to transfer data from AVR to STM32 there are better/faster/smarter solutions than UART (especially when you use soft serial on AVR either): I2c or better SPI. You should try out a SPI solution so you have the "native" serial on AVR without need for software slowdown and less processor circles (serial slow down completely the system on AVR and STM32). Only drawback: You need four lines instead of two. Some times ago I build a 4-voice synthesizer with 4 arduino nanos (as "voices") and one Tiva TMC123 as master device. As transfer protocol I used I2c without problems (oddly enough it was more stable than SPI)

User avatar
Pito
Posts: 1385
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TX2 RX2... Am I missing something?

Post by Pito » Fri Aug 12, 2016 5:57 pm

I2C and SPI are much faster and more sensitive to signal's quality - you would need hw signal drivers/buffers when using longer cables.. (>20cm for example)
Pukao Hats Cleaning Services Ltd.

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: TX2 RX2... Am I missing something?

Post by madias » Fri Aug 12, 2016 6:09 pm

Another silly question (didn't read the whole thread at once):
Do you use a common ground for ALL devices? Most problems occurs if no common ground is present.
Pito: your are right, it depends much on the length of the cables and transfer speed. Without using buffers you can also try to lower the data transfer speed (still higher than UART)
Edit: Yes, now I can remember, I used some level shifter (buffers) for my project. They are totally cheap and a really *must have* for any kind of using: http://www.aliexpress.com/item/20pcs-lo ... 11638.html (maybe you find in the meantime cheaper ones)
Edit2: more cheaper (0.19Euros/piece) : http://www.aliexpress.com/item/5PCS-Two ... 43189.html

User avatar
Pito
Posts: 1385
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TX2 RX2... Am I missing something?

Post by Pito » Fri Aug 12, 2016 7:38 pm

A "level shifter" does not mean "a buffer or driver". You need for example for SPI something like 74LCX244/245 drivers which are able to push nice rising and falling edges (a lot of current into the cable) over longer distances :)
With automotive you may try CAN :)
Pukao Hats Cleaning Services Ltd.

Nutsy
Posts: 237
Joined: Sun Jul 24, 2016 4:26 pm

Re: TX2 RX2... Am I missing something?

Post by Nutsy » Fri Aug 12, 2016 8:34 pm

The final build is going to be on a couple of PCBs with the controllers soldered on should be no problems with distance... But hardware serial should be find for this...

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: TX2 RX2... Am I missing something?

Post by madias » Fri Aug 12, 2016 8:55 pm

Pito wrote:A "level shifter" does not mean "a buffer or driver". You need for example for SPI something like 74LCX244/245 drivers which are able to push nice rising and falling edges (a lot of current into the cable) over longer distances :)
With automotive you may try CAN :)
Yup, but the n-channel mosfets BSS138 (on these level shifters) are little "drivers", for sure not the power of a 74lcx244, but more than a MCU pins do provide, but you need them twice for longer distances (directly after each MCU/device). So not for planning a circuit out of the box, but if you have plenty of them at home and you need some more cm you can try it with them :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest