Jump to content

Pybricks

Eurobricks Vassals
  • Posts

    80
  • Joined

  • Last visited

Everything posted by Pybricks

  1. Hey all, here's a video demo! https://user-images.githubusercontent.com/12326241/197208154-02750e82-edf4-4a33-9670-0bfa36374123.mp4 It's similar to a counter, but I use colors in this example.
  2. Both. The blinking light shows when the battery is low, but it is just an indication at that point. The hub will safely turn off later and save data, when the battery is very low. I imagine you are asking about running a GBC for a long time, not losing count when the batteries run dry? But please do help us test when we release it. If something isn't working, we can fix it :) And, you can do even better if you want to handle it in your own script. You can check the battery level in your code, and turn off/save when the battery goes below your preferred level.
  3. Once saved and powered off, your program and data will remain saved even after removing the battery. Yes, the hub will automatically shutdown on low battery, and the light will start flashing orange before that happens. See: https://pybricks.com/install/using-powered-up-hubs/ User data will automatically be erased when you update the firmware or if you install the original firmware again.
  4. Good idea. Could what you have in mind perhaps be done with existing MicroPython functions? For example, use data = b"Hello" len(data) # This equals 5 We've figured it out -- we've been doing this for a while . This has been made possible due to a few recent development breakthroughs. A big one came from MicroPython itself. Using their improved file format of compiled programs, we can keep the program in memory after it ends. Then we can properly save it when we power the hub off. This is much easier than saving data while the hub is running, which is what prevented us from doing it until now.
  5. Question for those who have asked about data storage. What do you think of the following approach? # There will be 128 bytes you can read and write. # The data will be saved when you turn the hub off. # To write some data: hub.system.storage(offset=5, write=b"Hello, world!") # To read some data: data = hub.system.storage(offset=12, read=6) print(data) # This will print b"world!" Is this flexible enough? Is there any functionality that seems missing? Who is excited for this feature? Oh... and what if I told you programs will be saved on the hub without re-installing?
  6. Not yet, but we're laying the groundwork for it as we speak. That includes saving the program on the hub without having to reinstall. If you want this feature, it would be great if you want to open an issue here: https://github.com/pybricks/support/issues Thanks!
  7. Thanks for submitting the bugs! That really helps us keep track of things, and mark them as done when they are fixed.
  8. @BatteryPoweredBricks, it looks like you might have found a bug. Would you mind posting a message here? https://github.com/pybricks/support/issues It would be great if you want to share your connectivity issues in a separate issue. There's a chance this affects other people too. Thanks for the help! @Lok24 and @vascolp: We have made some progress in regards to saving data on the hub. How much space would you need to make this a useful feature? 10 bytes? 100? 256? more?
  9. Yes, or try the very latest version using the instructions linked above if you can’t wait for the next beta in a few weeks :) It would still be very useful if someone wants to try that experiment above with the Powered Up app, to find out what the values really are.
  10. We use the values stored in the motor itself. We believe LEGO choose these so that most users can actually reach that speed. Without Philo’s special 9V supply :) But it is possible that the Powered Up app uses different defaults. To find out, just let the motor run at 50% speed and use a stopwatch to let it run for two minutes. Write down how much the motor moved in this time. Do it a few times for each motor type. Then we can calculate the speed. We’re happy to update our defaults to make them the same.
  11. Yes. And to be sure, you can click on "compatibility" next to each sensor. You'll see a list of all the hubs with a checkmark if it's compatible. For example, try it for the infrared sensor here. Which hub and which sensor would you like to use? Maybe we have an example program already. We've recently made some corrections to this. The default values are defined here. For each motor, you can see the value for "settings->speed_max". Let me know if you think that some of these values are not right. To try the new firmware with these fixes before we release it officially, you can follow these instructions. You can read the settings from the motor like this: from pybricks.pupdevices import Motor from pybricks.parameters import Port my_motor = Motor(Port.A) max_speed, acceleration, max_torque = my_motor.control.limits() print("max speed:", max_speed) print("acceleration:", acceleration) print("max torque:", max_torque)
  12. Hey @Polarlicht, glad to hear you got it working! For your questions, I recommend playing around with just a hub and a motor, instead of everything built in. Then you can easily see what the lights do, what happens when you run motors, what happens when you turn it off, and so on. You can try many of the short example programs in the documentation on the right hand side to get some ideas. For specific questions about example projects like the volvo, please start a discussion here: https://github.com/pybricks/support/discussions That way the community member who made that program can help you. And others with the same question will be able to find it later.
  13. I'll try to answer some of the questions here. Let me know if I missed anything. ---- Copy pasting @Polarlicht, since copy-pasting doesn't seem to work well on mobile phones, you could do this instead: - Save the program on your computer. Just paste the contents in a text editor and save it as my_program.py. - Send it to your phone using email or something else. Personally I use Dropbox on all my devices. - In Pybricks Code, use the open button to upload your script. This should preserve all the spacing. Or get a Bluetooth dongle for your PC for a few euros/dollars. Looks like you've got one on the way already. Nice! ---- How to check programs stored on the hub Usually, it's best to test your program before you save it on the hub. That way, you can easily see output and errors in the app. But you can also do that for a program already stored on the hub. To do that: - Turn the hub on. - Connect via Bluetooth in Pybricks Code. - Click the button to start the program saved on the hub. - Now you can read any output or errors in the app output window. --- Should we make a block language for Pybricks? Seriously. Would it be worth the effort? Would the community like to help make this happen? --- More example programs Thanks! Many of the programs on our site are made by the community, and we're certainly looking for more example programs. It would be cool to add a program like you describe. Would anyone like to make one and share it?
  14. This is already available. You can use the upload button to upload a script. We're working hard to make it easier to work with files. If you're curious, check out the beta release and see for yourself: https://beta.pybricks.com/ This is a great idea. If you post the suggestion here, there's a chance we'll make it work :)
  15. You can drag down the separator in the middle to increase the code canvas size. (Tap then drag down, may need to try a few times.) But our app isn't really intended for mobile use. You may want to consider getting a bluetooth dongle for your PC for a few euros/dollars. Any modern Bluetooth dongle (with Bluetooth Low Energy) should work. > Don't know if thats the problem nor how to fix that. You'll need to make sure that the code looks the same as the original. Perhaps keep the website open on your PC to compare.
  16. @Polarlicht: Indentation is the spacing to the left of each line. It sounds like copy-pasting didn't go quite right, but it's hard to tell from that screenshot :) You'll want to make sure that your code looks the same as where you copied it from. Perhaps you can try this version: https://pybricks.com/projects/sets/technic/42131-cat-bulldozer/powered-up-remote/ There's a "copy" button just above the code as well.
  17. Following up on @AVCampos' nice example for the set, we've made one as well. Thanks to @Jim for letting us borrow his set for this (and thanks for the tea!). You can find the code here. We only calibrate the function selector at the start. Since it's so easy to control the functions, it really doesn't seem worth calibrating the end points for the function motor. But let us know if you want to see a more detailed code example of how calibration can be done!
  18. Thanks! The program is here. For speed control, a P-controller with a position that linearly increases with time is all you need (So, I=0 and D=0). No matter the P value, you are guaranteed to reach the desired speed eventually for any weight or number of cars. This is true in theory and practice. So perhaps counterintuituvely, to achieve perfect speed control you don't actually need to measure speed; only position. And that's a good thing because that's all we have on a train with a color sensor. Indeed, it knows its position by counting the sleepers. We allow you to calibrate the color sensor for your track colors, so that should help if contrast is lower in your application. The hysterisis uses in this example isn't currently available for colors, but we perhaps we should add that.
  19. The train motors (and other DC motors without encoders) cannot be used directly for speed control. Back EMF cannot be measured by the motor or the hub. But you can get very good results by adding a color sensor to measure the speed by detecting the tracks: The shunter train won't need this though as it uses a motor that already has a rotation sensor. But if there's room, it's still nice to integrate the color sensor anyway in order to detect colors on the track.
  20. This looks fantastic!
  21. Do you mean converting any program automatically, or just this one in particular? This example code be translated as: from pybricks.pupdevices import Motor, ColorDistanceSensor from pybricks.parameters import Color, Port from pybricks.tools import wait # Initialize the devices. motor = Motor(Port.B) sensor = ColorDistanceSensor(Port.A) # Repeat forever. while True: # Wait for the sensor to see red. while sensor.color() != Color.RED: wait(10) # Wait 0.1 seconds. wait(100) # Run the motor backwards at 500 degrees per second, for 120 degrees. motor.run_angle(-500, 120) # Wait 0.1 seconds. wait(100) # Run the motor forward at 500 degrees per second, for 120 degrees. motor.run_angle(500, 120) I would encourage you to try out some of the examples in the documentation, and modify a few values and commands to learn how it works. Theoretically, we could develop a block language for Pybricks. But since the Powered Up app has something like that already, we will probably focus on other priorities.
  22. Since it's just an idea at this point, it's probably better to follow the link mentioned above for further discussion and questions about the low power mode.
  23. You can't set it from within the user program. Just like updating the firmware, changing the name occasionally is totally fine. But allowing users to do it in a loop that can run thousands of times per second is a different story. As I've mentioned before, perhaps you can consider alternatives. We've opened a dedicated discussion for preserving data using a low power mode here.
  24. It's not a matter of whether it's possible, but whether it's recommended . We always strive to make Pybricks 100% safe for everyone. This means that we use motors, sensors, lights, storage, and so on, within the same limits as the original application or firmware. If LEGO supported storing user code or data on the City Hub/Move Hub/Technic Hub from their apps, perhaps we will allow it as well. If you want a small hub with dedicated storage, you can also consider using the Essential Hub.
  25. For installation on the Prime Hub and Inventor Hub, please see this page. Please note that Pybricks for those hubs is still in beta at this time, so not everything will work yet. The main issue is that the City Hub, Move Hub, and Technic Hub do not have dedicated storage space for this kind of thing. Viewing this problem from another angle, perhaps you can make a program that doesn't turn the hub off when you press the button. It would be interesting to investigate how long the batteries will last in this case.
×
×
  • Create New...