Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
kH Robot
#1
I'm designing a kh automatic tester, that would work in 2 modes: standalone and connected to robo-tank.

The device has to be powered with 12v.

For the standalone mode, there aren't issue, but i don't know how to make the robotank connection.
i'm thinking in using an I2C bus, because it's stackable (and, more or less, a new I2C device won't use any pin on the robotank board, just add it with or without an I2C hub and you have done)... But there is an issue: I2C needs a common ground between both devices. As I have a different power supply, I can't use the GND coming from robotank or it will collide with the gnd coming from my power supply

Any idea ? I don't want to use (only) a wireless connection , the device must be connectable to robo-tank like it was native. Also, I don't like the idea to use some pins from the robo-tank (and which pins, anyway?)
Reply to top
#2
maybe the faster way would be to use an ethernet connection between robotank and the device. users can choose if running via wifi or by plugging an ethernet cable
Reply to top
#3
Yeah for expansion it gets limited quick, this is something I need to sort out for the controller but it's not so easy, like you say I2C is very nice to use but I really need to get away from this. It's especially bad for someone like yourself who wants to do everything, after adding extra pca9685's, ph maybe some Atlas circuits, now kH and I'm sure you have lots of other things stirring around. All this is setting yourself up for a buggy system no matter how much care you take or what buffers you use, don't ask me how I know. Now I take this very serious and the most external devices I want to see is two and that's connected with 4-12" jumpers. Overall that's pretty safe but still not right. I2C isn't used on commercial products due to this, serial such as RS232 or RS485 is common but still limited so most large module based systems use Canbus, I believe Apex is one of them.

A little off topic, I'm happy to report I've added validation to the Robo-Tank app for pca9685 as those are critical. Now whenever a pin on a pca9685 is adjusted it immediately reads the same pca9685 pin state to verify it actually switched, if it didn't switch it will send the command until it does update. This is now the best feature of the app and always will be.

As for the common ground that's necessary in most applications, just need an extra conductor to go with the signal cables.

Personally I don't like ethernet or wifi due to complex setup, lots of people can't find IP addresses etc... but it's certainly a better option than I2C, doesn't require any additional parts and is flexible, I think it's worth considering.

UART is what I used on my Arduino based controller between display and controller. It is better than I2C in terms of reliability but only one device can be connected to a set of UART pins so there's limits, Arduino has max of 3 sets, not sure about Pi. This also requires care with code to validate everything, if you create a checksum to send with data you can valid things like that. That's what should be done with I2C, I would do it on my pH circuit but can't apply required changes to reef-pi. You can setup the Pi USB port for UART so direct connection to Arduino etc.

I mentioned that LTC4311 buffer, it's just a bandaid for DIYers. Using the pca9615 is much better but requires one on each end. This will send the I2C signal down two lines, when it gets to the other end it compares both signals, if they are exact it accepts them as it's likely a valid reading, if the signals don't match when they arrive it means noise got in so it will discard. This is one route I've considered for the controller as it would be easy to implement and definitely helps but still not right.

https://learn.sparkfun.com/tutorials/qwi...-guide/all

So yeah CanBus is the best by far, all these issues disappear. It's used in most vehicles, automation and some aircraft as it's error proof. Overall it doesn't look to difficult to work with either but still a learning curve, there are libraries for Arduino etc which is a great starting point. You send data in a similar fashion as I2C with address etc except this is guaranteed to get where it's going in tact or you will know about it. You can also set priority on messages and select what modules are listening to specific data. All the heavy lifting and validation is done automatically in the chips which is what makes it great, when data is sent it sends a CRC checksum, when it arrives it recalculates the checksum based on the data it received, if it matches it knows message is in tact, if not it will discard and ask for that data again. If it can't find a target you can set off alarms etc.

I have a couple of these boards I've always been meaning to experiment with.

https://www.seeedstudio.com/CANBed-Ardui...r_products

That's about what I know, for your kH tester I think if you have extra memory use multiple connections, maybe I2C and ethernet/wifi and if you want to go all out do serial using a USB port on Pi. This required some configuration to the Pi so USB could work this way so you would need to verify it doesn't effect all USB ports or it might not be good as keyboards, mouse etc would be a problem. Ideally it would be nice to tell someone use USB in top right corner or such, if so maybe four could be connected. This is something I should be looking into as well as that is a nice solution with good supporting code and free ports which is always great.

Although I mentioned Canbus this isn't practical right now as it would take time to implement on controller and I still have a lot to learn.
Reply to top
#4
Thank you for the overview about the connection protocols.
I agree, ethernet/wifi could be difficult for some, but 99% of users, has working DHCP server, so both RoboTank and third-party devices could obtain a working IP address.

Then, the third party device like mine kh-robot could start a discovery protocol to automatically find the robo-tank server address, in example:

https://github.com/Rom3oDelta7/NetDiscovery

or, maybe better, avahi/mdns that are both standard protocol used on almost any device (mac, windows, linux, arduino):

https://github.com/khoih-prog/MDNS_Gener...rvices.ino

In this case you'll get a fully automated network mapping with no user intervention.

What we need is the remote-device being able to discover the robo-tank server, than with a custom defined set of APIs, the remote device could introduce itself to the robo-tank server and we are ready to go, because the server will know that a kh device is reachable at IP 192.168.1.56

This will work automatically with any network interface (ethernet or wifi) as long both devices are reachable on the same network (in 99.99% is always like this)

Do you have an wired network ? Ok, just plug robo-tank to the network, power on the wifi-enabled remote device and you'll see the robo-tank . If the remote device has an ethernet card, plug it and you'll see in the same way.

I think it's more hard to explain that implement (at least the network discovery). I'll try to do some test with one Arduino One and one ESP32, let's see if with ZERO configuration on arduino/esp32 i'll be able to see that Robo-Tank is running at a defined IP....
Reply to top
#5
I think wifi/ethernet is the way to use for third party devices. If properly developed, they are user-proof.

Quick sample between an ESP32, a linux device (my laptop) and the Robo Tank.
The ESP32 as a test firmware with only the wifi SSID and Password configured, nothing more, everything else is automatic.

This is a discover run from my laptop, as you can see in the bottom, there is a Robo-Tank Controller and a kH-Robot announced.
the kh-robot is the ESP32 test firmware.

Code:
Found service 'shellyswitch25-BCDDC2774FFB' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shelly1-22FECF' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shellyswitch25-D8BFC01A3146' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shellyswitch25-40F520178518' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shelly1-1D9BFC' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'HP LaserJet MFP M28w (7EEF13)' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shelly1-22538A' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shellyswitch25-BCDDC277503B' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shelly1-25AB5A' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shellyswitch25-84CCA8A0BEBB' of type '_http._tcp' in domain 'local' on 2.0.
Found service 'shelly1-25AA26' of type '_http._tcp' in domain 'local' on 2.0.
Service data for service 'Robo-Tank Aquarium Controller on gandalf-reef' of type '_robotank._tcp' in domain 'local' on 2.0:
    Host gandalf-reef.local (192.168.1.113), port 443, TXT data: ['role=robotank']
Service data for service 'Robo-Tank kH-Robot' of type '_robotank._tcp' in domain 'local' on 2.0:
    Host kh-robot.local (192.168.1.147), port 80, TXT data: ['role=khrobot']


This is the output from the esp32.
You can see that it connect to the wifi network, register itself as khrobot device and then starts looking for the RoboTank controller (a node having "role=robotank"), until it find it with it's ip address. All automatically. every 5 seconds (it's just a test) it does a new scan.
Code:
Hard resetting via RTS pin...
========================================================================== [SUCCESS] Took 18.83 seconds ==========================================================================
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on /dev/ttyUSB0  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

Hello World
Connecting to WiFi...
Connected.
kH Robot Local IP: 192.168.1.147
Announcing kH-Robot ... Done.
Browsing devices inside Robo-Tank Aquarium Controller Network _robotank._tcp.local. ... 1 device(s) found. Looking for the controller ...
Found a Robo-Tank Controller 1: gandalf-reef (192.168.1.113:443)

Browsing devices inside Robo-Tank Aquarium Controller Network _robotank._tcp.local. ... 1 device(s) found. Looking for the controller ...
Found a Robo-Tank Controller 1: gandalf-reef (192.168.1.113:443)

Browsing devices inside Robo-Tank Aquarium Controller Network _robotank._tcp.local. ... 1 device(s) found. Looking for the controller ...
Found a Robo-Tank Controller 1: gandalf-reef (192.168.1.113:443)

Browsing devices inside Robo-Tank Aquarium Controller Network _robotank._tcp.local. ... 1 device(s) found. Looking for the controller ...
Found a Robo-Tank Controller 1: gandalf-reef (192.168.1.113:443)

Browsing devices inside Robo-Tank Aquarium Controller Network _robotank._tcp.local. ... 1 device(s) found. Looking for the controller ...
Found a Robo-Tank Controller 1: gandalf-reef (192.168.1.113:443)

From now on, the kh-robot is able to connect to robo-tank, without any human intervention. Just the initial wifi configuration (if using a board with ethernet, like a RPI or Arduino+EthernetShield, even the wifi configuration is not needed)

This is the discovery run from the robotank controller, properly seeing the kh-robot announced as kh-robot device
Code:
$ avahi-browse -tfr _robotank._tcp
+  wlan0 IPv6 Robo-Tank Aquarium Controller on gandalf-reef _robotank._tcp       local
+  wlan0 IPv4 Robo-Tank Aquarium Controller on gandalf-reef _robotank._tcp       local
+     lo IPv4 Robo-Tank Aquarium Controller on gandalf-reef _robotank._tcp       local
=  wlan0 IPv4 Robo-Tank Aquarium Controller on gandalf-reef _robotank._tcp       local
   hostname = [gandalf-reef.local]
   address = [192.168.1.113]
   port = [443]
   txt = ["role=robotank"]
=  wlan0 IPv6 Robo-Tank Aquarium Controller on gandalf-reef _robotank._tcp       local
   hostname = [gandalf-reef.local]
   address = [2001:b07:xxxxxxxxxx]
   port = [443]
   txt = ["role=robotank"]
=     lo IPv4 Robo-Tank Aquarium Controller on gandalf-reef _robotank._tcp       local
   hostname = [gandalf-reef.local]
   address = [127.0.0.1]
   port = [443]
   txt = ["role=robotank"]
+  wlan0 IPv4 Robo-Tank kH-Robot                            _robotank._tcp       local
=  wlan0 IPv4 Robo-Tank kH-Robot                            _robotank._tcp       local
   hostname = [kh-robot.local]
   address = [192.168.1.147]
   port = [80]
   txt = ["role=khrobot"]

Even robo-tank is able to reach the kh-robot
Reply to top
#6
I agree, networking is already a requirement so what's a few more devices, especially if it can be managed well and it looks like you're on the way. I really wish I could understand all that, I know very little about networks, it never interested me but I'm going to have start learning. Would you be able to move the code you added to my app to it's own file so it's just a network scanner? I have no idea where to start and something like this would get me going in the right direction. Then I can experiment finding things and how to send data back and forth.
Reply to top
#7
i'll try in the next days
Reply to top
#8
Thanks, no rush.
Reply to top


Forum Jump:

Current time: 04-28-2024, 01:49 PM