Search the Community
Showing results for tags 'legoino'.
Found 2 results
Cornelius posted a topic in LEGO Technic, Mindstorms, Model Team and Scale ModelingI am very happy about all the feedback and contributions which take the library to that step. Today version 1.0.0 of the legoino library is released! After over a year of learnings and feedback i have reworked the library to be more consistent and to make some things easier. Unfortunately this was not possible without breaking changes. This means some functions and methods has to be removed or renamed. To make the migration of your sketches easier, just have a look into the Migration guide provided on the github project page: Migration guide New features Duplo Train support Enriched Motor commands (maxPower, brakingStyle) Support of setAbsoluteMotorPosition, setAbsoluteMotorEncoderPosition Callbacks for changes on hub properties and sensor values PowerFunction (IR) functions included Hub Emulation (powered up to powerfunction translator) Adding of getHubName rework of log messages to the standard log_d, log_w, log_xx messages. Log levels could now be switched via the Arduino environment Contribution I am very happy about the whole community who participates in that library and contributes with ideas and your cool projects that uses the legoino library. If you have any questions, ideas or need help, you can just contact me. Looking forward to all the cool stuff you are building with the new version of the library. Cheers, Cornelius
Toastie posted a topic in LEGO Train TechDear All, the Crocodile (#10277) made me change my mind: Before knowing about the set, “no more trains” due to “no more space” on my layout was directing me to other LEGO related activities – mostly concerned with improving things on the layout. Which is – hmmm – nice but … So 10277 was announced and it was 2 minutes after it appeared on the German S@H website that I ordered it. It arrived 2 days later and was built the very evening. Folks on EB and elsewhere reported way earlier on improvements – I copied that and added my own ideas. So the Croc was there, now it needed an appropriate display – with no space on the layout … Solution: Mount some track to the wall (https://www.eurobricks.com/forum/index.php?/forums/topic/179240-mod-10277-and-on-and-on-another-crocodile-mod-%E2%80%A6/). Used my cell phone to make it go back and forth, thought about automation. And then Cornelius Munz’ Legoino software, which allows connecting to and control PoweredUp (PUp) servers (my understanding is: currently the 2I/O and the Boost hub) got me all excited. The hardware platform supported is the ESP32 line of devices. Several solutions have been already presented here on EB in the Mindstorms forum and elsewhere, sorry for not providing references here. My take on learning that ESP32 boards can connect and control PUp hubs was: They cost less than 10 € a piece, have ample of memory and – coming from the “3(+) inputs/3(+) outputs” world of LEGO intelligent bricks (RCX, SCOUT, NXT, EV3) as well as PUp (4 Control+/6 Spike) – there are almost “uncountable” I/O pins on these boards. Make it 20+, depending on the board. In conclusion: One dedicated ESP32 board for one single PUp hub is hardly affecting my LEGO budget … and no cell phone or tablet device is required at all. And here we go. The idea is: The Crocodile goes back and forth on elevated track mounted to the sloped ceiling of my room. See above link. The endpoints are defined using sensors, otherwise timing errors may add up – and a crash at about 1.5 m height may result in severe damage … There should be a defined acceleration and deceleration phase – and not just full blast ahead and full stop at the distant and close terminal. One possible solution is: 4 sensors are detecting the position of the Croc: Endpoint right, endpoint left, deceleration points in between. This is what I have implemented in terms of a stretch of track consisting of curved and straight tracks to show the Croc’s abilities, and a C/C++ program using a jOYiT ESP32 nodeMCU (with 30 pin GPIO exposure), four line-tracking TCRT5000 based sensors from keyes; looking upward from the track sleepers, the Arduino IDE, the ESP32 libraries/programmers for the IDE, Cornelius’ Legoino libraries to access the 2I/O hub of the Croc, a small 128x64 OLED display from jOYiT to show the status and what is happening, the Adafruit libraries for the display, and four push buttons: Go left, go right, start/stop, emergency. Solution/workflow: Power-up ESP32. Wait for Croc’s 2I/O hub to be turned on. When not at “initial” Start/Stop position (i.e. at right sensor), use the Left/Right buttons to locate the Start/Stop position; pressing the buttons move the Crocodile at low speed as long as they are pressed. When the Start/Stop position is reached (i.e., the right detector fires), both buttons are disabled and only the Start/Stop button is enabled – the Emergency Stop button remains always enabled. Press Start/Stop once: Make one return trip. Press twice: Do that indefinitely. The button “surface” shown on the display lets you know the mode: Open circle around Start/Stop: Loop forever; inverse colors (white background/black letters): Loop only once. Emergency button: Full stop (issued 4 times to be sure) and return control to Left/Right manual control buttons until Start/Stop position is reached again. The OLED display further always shows the battery level and the BLE signal strength. That’s it. Here are a couple of photographs (video may follow – but I guess you guys are getting the idea from the images). Crocodile and Controller … it says “Turn on Crocodile” and scans the 2.4GHz radio signals in the room – when pushing the PUp hub’s on/off button, Legoino connects to the hub with the correct ID. The controller’s front panel. Left to right: 128x64 OLED display using I2C communication using only 2 GPIOs of the ESP32 board!), button “Go left”, button “Go right”, button “Emergency”, button “Start/Stop”. The LEDs below the buttons, left to right: “PWM applied when going left”, “PWM applied when going right”, “Emergency (or attention)”, “Running”. The brightness of the left/right LEDs are controlled by GPIOs configured for PWM mode. Top left: Display shows “Locate Start Position”, this means Crocodile’s right rail guard is not aligned with the right stop sensor. Pressing the button "Left" or "Right" slowly move the Crocodile. Top right: Rail guard aligned with the left stop sensor: The display changes to “Start/Stop”. The red “ramp” is for safety reasons only; so far not used once. Upon letting the Crocodile moving onto the ramp at full speed, it slides up and the driving wheel lose contact with the rails. Bottom left: Pressing "Start/Stop" fires the run sequence: Accelerate to max speed with given time intervals, when the left "slow down sensor" fires, decelerate to minimum speed and then stop when the left stop sensor fires. Wait for two seconds, accelerate and do the same thing with the right sensors. Stop at right stop sensor when Start/Stop button is pressed only once, repeat the sequence indefinitely when pressed twice. Bottom right: The LEDs brightness as well as the display values show the current PWM power applied to the motor. Close-up of the sensors used (top) and the Croc's rail guard triggering the sensor. Couple of images showing the brick-built case. Bottom right: I glued a 2x2 tile onto the ESP32 – this secures its position when assembled. Some soldering and mounting details. The sensors need 3 wires: 3.3V, ground, and signal. There is an 8 wire cable hiding behind the track: An USB power supply delivers 5V/GND to the ESP’s "Vin" pin. The ESP in turn delivers 3.3V/GND to the sensors. 4 wires are used for the 4 sensor signal lines. TO-DO: The acceleration and deceleration phases are programmed as a “ramping” routine with defined power step size (5% PWM) and dwell time per step (300 ms). Minimum "moving" power is 25% PWM as the Croc stalls otherwise. Maximum power is 80% PWM. This is OK but not “cool”. Cool would be to program the 2I/O hub upon startup with acceleration and deceleration profiles. The firmware/LWP3.0 protocol allows to do that – but this feature is currently not implemented in Legoino. Secondly, using the LPW “speed” instead of “power” LPW commands would invoke the PID controlled motor operation. I did that already with my VB6 code – works beautifully well: At speed “5” the Croc negotiates the curves and straights at almost constant – well – speed. This is not possible with “power 5” – it just does not move at all. This works of course only with PUp motors with internal rotation sensor – the PUp L-motor in the Croc features that. But again: This is not implemented in Legoino yet. Will be available at some time in the future though! Happy to share code, but this is a (very) “tailored” project. Best wishes, Thorsten.