Welcome, Guest
Username: Password: Secret Key Remember me

TOPIC: Hacking my new SafePet Rotating Litter Box for Cats

Hacking my new SafePet Rotating Litter Box for Cats 1 month 4 weeks ago #18091

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 487
  • Thanks received: 46
Yes that works for a shared serial line connected to several devices. When I said shared serial channel though, I meant that it is buffered, independent, and only linked by software. The daisy chaining I am doing is software linking serial1 to serial2, and serial2 to serial1. Of course that is over-simplifying it tremendously. It's more server.client[1] -> serial1 and vise versa with the ESP injecting output to that connection also, and listening to its counterpart.

Hacking my new SafePet Rotating Litter Box for Cats 1 month 4 weeks ago #18092

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 487
  • Thanks received: 46
I got a pretty good idea, maybe not original I'm sure, but it is totally doable.

For system messages between modules, I will wrap them in a packet headed by a unique character, or character sequence. When that is detected by any of the reporting systems, it will buffer it separately and act on it. I have timer IRQ handling in all my sub-systems so that can be used to keep track of a time out. After all, if the packet is machine sent, it will be all at once and not full of delays like human interaction. If the system communications packet passes the timeout phase, then it will be treated as a system message. If it doesn't, then the characters will just echo like they were human interaction.

To put it into perspective, the human interaction via a telnet putty session is to test commands and manually look at data and variables. The telnet connection will be for the host server to interact with the project via MQTT. The code I wrote in the ESP8266 can handle multiple telnet clients, although I only really need two. If for some reason, another project needs to communicate with the current project, it can open a telnet channel and be a client to communicate as well. This is great for redundancy in case the host server is down. Using this topology, I can create a database storage project that handles data acquisition should it find that the host server has left the building so to speak. Then when the host is up, it can dump to it its cached data. Autonomy is being coded from the simplest worker sub-system, up through the hierarchy of the project's main system and of course to the main server.

There is lots to do to make this happen, but I am trying to foresee the possibilities and code features for their eventual activation.

Hacking my new SafePet Rotating Litter Box for Cats 1 month 3 weeks ago #18093

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 487
  • Thanks received: 46
SET BACKS

I have been running into issues with the SMT32DUINO firmware I have (had) loaded on one of my STM32F103 boards, so I decided to revert back to using STLINK to program it. The issues are certainly not STM32 for Arduino's fault at all, it's just that I cannot program it with PlatformIO at all, and there were other work arounds I could not get around.

I have so many of these blue pill clones though that I decided to build another prototype with identical layout except one is STLINK firmware and the other is STM32DUINO firmware. And the winner is? We will see.

But now I stepped into some dung so to speak with the Nucleo F411RE board I use as a STLINK programmer. To the point were I am going after windows drivers again, and looking for adequate and stable STLINK firmware. More when I solve it today.

Hacking my new SafePet Rotating Litter Box for Cats 1 month 3 weeks ago #18094

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 487
  • Thanks received: 46
OK, everything is going great!! I added a connection to the STM32F103 (blue pill) reset pin from D1 of the ESP8266 (Wemos D1 Mini Pro). At first, this worked fine, resetting the blue pill as part of the ESP8266 start up process. I ran into trouble though when trying to program the Blue Pill. The reason was because the reset pin was still being held high by the ESP8266 and that was causing my ST LINK to hang. I fixed this by setting D1 on the ESP8266 back to INPUT after toggling the line low then high. Now it still works as expected, but allowing the pin to float and to be utilized for programming.

I added a couple of delays here and there to allow for a comfortable window for the Blue Pill to reset and get ready for the first system message from the ESP8266... a EPOCH encoded time stamp of the current time obtained from an NTP server. The Blue Pill gets the command and updates the RTC perfectly. Mission accomplished!

I added some commands on the Blue Pill, which are just testing and house keeping for manual input through a telnet connection. Module RESET, send the time, clear the screen, that sort of thing. All work perfectly!

I still haven't wrote in the system message packet feature. That is the task for the day! After all, if it works, break it and then fix it again, and hopefully enjoy the new features. :)

Hacking my new SafePet Rotating Litter Box for Cats 1 month 3 weeks ago #18095

  • Jon Chandler
  • Jon Chandler's Avatar
  • Offline
  • Moderator
  • Posts: 360
  • Thanks received: 350
You have been busy! Glad to hear you got the bugs worked out.

Today I have been rushing around trying to deliver a long-overdue project that needs to be used tomorrow. Much programming from Friday - Monday to make changes necessary for the revisions, including reversing the bits in a byte (no, there is no easy way to do this - I resorted to a lookup table. Add to that a grumpy DS3231 RTC. It doesn't like it when the PIC is programmed and sometimes decides to quit working until the power has been removed for a hour or more after code is loaded! Remove power, wait a while...long while...and it's happy again when powered up.

Firmware was mostly complete last night - well the major features anyway. Today I was going to duplicate my dev board, with mostly SMT parts. I soldered a handfull of passives down using my solder paste dispenser and hot air....what a mess. I scraped them off the board and tried again. Nope. Not my day. Deliver dev board it is!

Hacking my new SafePet Rotating Litter Box for Cats 1 month 3 weeks ago #18096

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 487
  • Thanks received: 46
Are you using C++ Jon? To flip the bits of a byte, just XOR it with 255 (11111111) and your result will be a zero where there was a one.
decimal 170 (10101010) xor decimal 255 (11111111) = decimal 85 (01010101)
// Example program
#include <iostream>
#include <string>

int main()
{
  uint8_t a=170;
  uint8_t b=255;
  
  std::cout << unsigned(a) << " XOR with " << unsigned(b) << " is " << unsigned(a xor b) <<"\n";
}
170 XOR with 255 is 85
I would imagine it is the same as subtracting the value from 255, as 255-170=85
// Example program
#include <iostream>
#include <string>

int main()
{
  uint8_t a=170;
  uint8_t b=255;
  
  std::cout << unsigned(a) << " subtracted from " << unsigned(b) << " is " << unsigned(b - a) <<"\n";
}
170 subtracted from 255 is 85
Only doing it with operators like AND, OR, XOR, bitwise shifts (<< >>) is more assembly friendly. :)

As far as the DS3231... I have the same issue with modules connected in a system and then programming one or more of them. It is usually because lines are left to float during programming, or they become noisy as the high speed data is shifted in. Decoupling caps usually fix that for me, or taking the connected system offline via reset or even disconnecting before flashing the module causing trouble.

As far as the hour unplugged... possible maybe that it crashes in very low power mode and a cap continues to feed it until drained? There is a reset pin, does it still whack out even when reset?

Man am I glad my STM32's have built in RTC's!! :)
Time to create page: 0.243 seconds