Jump to content
 

Raspberry Pi Pico


DavidB-AU
 Share

Recommended Posts

4 hours ago, melmerby said:

The problem seems to be that some programs are trying to import things that don't exist/can't find

e.g. if you use the micropython build for Pico from the Raspberry Pi website, when you run a demo for the Pimoroni Pico Explorer the 'drivers' for the display and motor driver aren't there.

Keith,

 

I think that the simple truth is that you need to download a .uf2 file to your Pico that contains all the modules that your programs are going to use - and at the moment, that does look a bit messy since this is all very new and things are being updated in real time ("it's still steaming in the morning air" as I said in an earlier post).

 

There certainly seems to be:

  • a uf2 file produced by the Raspberry Pi folks, which I think is quite vanilla
  • a uf2 file produced by the Pimoroni folks, which I think addresses their hardware
  • a uf2 file from the Adafruit folks for circuitpython

The grousing mentioned by Kev above seems aimed at the Pimoroni material which clearly had problems.

 

It may be that some of the programs you're trying to run don't make it clear which uf2 to use and clearly if stuff is missing, it ain't going to work. Alternatively, there are probably still bugs in that there code...  :wacko:

 

Yours,  Mike.

  • Informative/Useful 1
Link to post
Share on other sites

  • RMweb Premium

I tried the RPi build and it didn't have support for the display & motor driver on the Pimoroni board

 

I tried the Pimoroni build and it did have support for the board but the demo was very limited.

 

I was hoping there would be a demo to exploit the features and it was very basic, just some monochrome text on the screen and a buzz from the speaker whilst the motor is driven back and forth and reacting to the push buttons.

 

Another Pimoroni app for the Pico had a nice tumbling ball demo in full colour but written for a different size screen and hence it worked very nicely but only part of the screen was used.

 

I would like to be able to add modules so that other hardware can be used but I can't see how.

 

I suppose I should put the Pico in a drawer for a while until more support is available.:scratchhead:

 

 

  • Agree 1
Link to post
Share on other sites

  • 1 month later...

I have been toying with the Pi Pico since not long after they came out, alongside other MCU I wanted something with a bit more ram, the duel core stuff is easy to use - not played with PIO as yet but plan to.

 

they can easily drive servos, use a PCA9685, this will take the 3.3v input on the I2C bus, then accept a 5v driver voltage and easily drive 16 servos - driving this from the Pico means creating a little bit of a driver but its not hard to do - have an example of my desk at work driving a pair of them.

 

they are much better for driving screens than the Arduinos as they can have a proper frame buffer inside and can easily let the second core manage actually updating things (again you need to write your own drivers but again its not that hard, its just shifting bits & bytes about)

 

key though is the things are dirt cheap, project I have some part on order for is a handset for a DCC++ system to use a Pico, operating a rotary encoder a few buttons and a 320x240 colour touch screen - then talking over the serial interface.

 

these things are very powerful, but cheap enough to dedicate one to managing a keyboard if needed (e.g. a pico is cheaper than a dedicated keypad controller IC..)

 

they do PWM very nicely for variable brightness of LEDs, and the low current output is managed easily by using transistors to control the actual LEDs anyway.

 

so far the only drawback has been the way they act as a slave in SPI mode meaning its hard to pretend to be something else.

 

but as a controller for point servos, signal servos, colour light drivers, serail interface hubs, screen drivers etc they are very hard to beat if you don't need wifi or bluetooth.

 

the Windows toolchain though is dire, I finally got a Pi400 where its a lot easier

  • Informative/Useful 2
Link to post
Share on other sites

Incidentally if anyone wants a hand using one of these little beasties to date I have example code to:

 

- driver servos via the PCA9685 (creates a servo controller class that can be used directly but also an individual servo class that allows for things like custom min, max and central positioning)

- drive a SSD1306 OLED display, goes a bit beyond the adafruit drivers with clipping rectangles, drawing logic modes etc (I was bored)

- drive a custom dot matrix display made from Max7219 ICs, treats these as a display, allows custom fonts etc

- DFRobot Player Mini MP3 player

- audio "tone" control using PWM for multiple voices

 

I've also used them to talk to 74HC165 & 74HC595 shift registers and similar

 

talking to EEPROM chips shouldn't be hard (or indeed anything on  the I2C bus)

 

not yet tested the nRF24L01+ radios out, they shouldn't be too hard to work with and will shortly be working on a colour TFT screen and touch panel driver, I've already got for a different MCU a touch screen "window" interface library thats a mess but works

  • Like 1
Link to post
Share on other sites

  • 2 weeks later...

@aleapardstail    I am intrigued that you have got a pca9685 board working with a Raspberry Pi Pico. I gave up trying but do have 8 servos running directly from 8 GP pins on the Pico which control 8 sets of points on my n gauge layout. I added Bluetooth control from an old smartphone and I'm glad to say all is working well.

 

I would be grateful to see the code you wrote to drive the pca9685 board. I take it it is written in micropython. Many thanks in advance.

Link to post
Share on other sites

5 hours ago, Auchavan Yard said:

@aleapardstail    I am intrigued that you have got a pca9685 board working with a Raspberry Pi Pico. I gave up trying but do have 8 servos running directly from 8 GP pins on the Pico which control 8 sets of points on my n gauge layout. I added Bluetooth control from an old smartphone and I'm glad to say all is working well.

 

I would be grateful to see the code you wrote to drive the pca9685 board. I take it it is written in micropython. Many thanks in advance.

 

code is C, dug up the PCA9685 IC data sheet and worked out what to tell it, don't have the machine in front of me right now with the code but will dig it up - actually driving them over the I2C bus was very simple, have expanded it a bit to allow for stuff like slow speed control etc.

 

the code is very easy to use, basically there is a "controller" object that does the work and can be used to drive servos directly to angles (by angle -90 to +90) using default values and a servo object that can sit on top that can work with different default values for the range etc.

 

will dig it up and post it along with how to use it, the actual programme has other stuff for an OLED display and touch panel controller but its easy to extract the servo bit into its own example and use it.

 

its basically:

 

- create the global object

- initialise it with a call to a function

- then as desired set servos to a desired angle

 

using the extra servo object just adds one of them, with a pointer to the controller its on, can then be called by name with an angle and will just do it, you have a pair of function hooks for callbacks when it starts and stops moving if you want to update a panel.

 

give me a day or two, its on my pi400 currently at work

 

have a few useful bits of code for these little things

Link to post
Share on other sites

8 minutes ago, Auchavan Yard said:

@aleopardstail  Thanks for your prompt reply. I will do my best to translate your code to python. If nothing else it will give me pointers to what I was trying to achieve.

the basic techniques of what commands to send should translate easily enough, my knowledge of python is about the same as my knowledge of deep space navigation...

Link to post
Share on other sites

  • RMweb Premium

If you were using C on a Pico would an Arduino library be usable with some adaption?

The reason being I have been playing with TMC2208 silent drive stepper motor drivers but there isn't a Pico library for them.

 

What is the advantage of Python over C++?

Edited by melmerby
Link to post
Share on other sites

some libraries will convert, some won't a lot depends what they do - anything that uses timers will be awkward as they are very different on the Pico, stuff thats using the hardware serial busses and the library is really just wrapping commands to send should be easier.

 

that said the RP2040 is a very different beastie.

 

not tried the TMC2208 so can't comment, but if an arduino can do it the RP2040 almost certainly can, even if its a very manual process shifting individual bits about. I have had one of the stepper motors the arduino starters come with though working on a pico, its mostly just setting bits

 

I don't use python but I gather the main differences are that it runs a lot more slowly, but you can develop things a lot faster and the language manages a lot of things for you like memory allocation, string concatenation etc.

 

pays yer money etc.

Link to post
Share on other sites

the key for the timers will be cracking using the PiPico to both encode and decode a DCC data stream, hoping to get work working as an accessory decoder as they are wonderfully cheap devices and should be able to manage the stream wither via PIO (not played with that yet) or by letting one of the two cores deal largely with that and the decoding, leaving the other for "user functions" to do something with it

Link to post
Share on other sites

1 hour ago, Auchavan Yard said:

@aleopardstail  Many thanks for sharing your code. Just as python is a mystery to you so C is just the third letter of the alphabet to me! But it will be fun trying to make the conversion. Thanks again.

 

I suspect it should be quite simple, once you can read a byte from the I2C bus and write one to it the rest is just working out what to put in what register.

 

trick seems to be to set the frequency (which is IIRC two registers) then its four registers to set each servo - basically write four bytes, the servo updates only on the 4th byte

 

the bits you probably want are in the "controller" object, specifically ".writeRegister(reg, value)" and ".setFrequency()" which has the calculation in it, you will probably find from there you can make a servo move and once you have that you will be off and flying

 

and likely with a lot fewer lines of code to do it

Link to post
Share on other sites

On 08/04/2021 at 18:17, aleopardstail said:

the key for the timers will be cracking using the PiPico to both encode and decode a DCC data stream, hoping to get work working as an accessory decoder as they are wonderfully cheap devices and should be able to manage the stream wither via PIO (not played with that yet) or by letting one of the two cores deal largely with that and the decoding, leaving the other for "user functions" to do something with it

Hi,

 

Someone on the internet has managed to send loco speed packets using the Pico PIO and using MicroPython for the higher level control. Google DCC generator using Raspberry Pi Pico PIO (youtube video).

 

There are cheaper microcontroller boards (from China) but I'm interested in the Pico as it may be around for some time and software support will probably be better (also the PIO has potential).

 

Regards

 

Nick

  • Like 1
Link to post
Share on other sites

8 hours ago, NIK said:

Hi,

 

Someone on the internet has managed to send loco speed packets using the Pico PIO and using MicroPython for the higher level control. Google DCC generator using Raspberry Pi Pico PIO (youtube video).

 

There are cheaper microcontroller boards (from China) but I'm interested in the Pico as it may be around for some time and software support will probably be better (also the PIO has potential).

 

Regards

 

Nick

 

oh now that I will have a look at thanks, not experimented with the PIO stuff as yet but it looks very powerful.

 

there are some cheaper boards, but not many sub £3.60 ones and not with this sort of capability (though the ESP8266 WeMos D1 mini is very nice if you don't need to many GPIO pins and do need wifi and its not a lot more)

Link to post
Share on other sites

  • 1 month later...
  • RMweb Premium

You can program the Pico using the Arduino IDE.

 

There is an extension in the Arduino board manager section which supports the Arduino Nano Connect which has a Raspberry Pi RP2040 processor and included is support for the Raspberry Pi Pico itself.

(The two organisations have been co-operating)

 

As a test I uploaded (unmodified) the basic Arduino Blink.ino to the Pico and it works.

 

Presumably this means the standard Arduino libraries would work?

That's something to try.

 

Edited by melmerby
  • Informative/Useful 1
  • Interesting/Thought-provoking 1
Link to post
Share on other sites

On 10/04/2021 at 14:17, aleopardstail said:

ohh that does look very interesting, blue cab lights though? I mean really....

 

amazed how little code that took, don't speak python but the PIO bit should be the same in any language (I think there are only 16 actual instructions)

Hi,

 

The PIO assembler code for MicroPython is not quite the same as for the C/C++ SDK.

 

I'm guessing this was in order to simplify getting code compatibility with MicroPython and its IDEs.

 

It certainly complicated my work trying things out in MicroPython before writing a C/C++ version.

 

Regards

 

Nick

Link to post
Share on other sites

Still working with these beasties, added the ability to read/write to and from an EEPROM IC, its not an optimised library (it writes byte by byte and not in pages for example) but it does for what I want, its also set to 8k EEPROM only.

 

Still not gotten round to playing with PIO though

  • Like 1
Link to post
Share on other sites

  • RMweb Premium

I have been playing around with some Arduino sketches.

My conclusion:

If they are simple sketches and don't contain any included libraries - they will work OK

If they contain included libraries they may work, depending on the library.

e.g.  TMC2208Stepper_h  silent drive stepper does not work. The compile fails part way through and the error points to incompatibilty with the processor core (RP2040)

However Wire.h, Adafruit_LiquidCrystal.h & Adafruit_VL6180X.h do seem to work as the sketch compiles (but yet to be properly tested.)

  • Informative/Useful 1
Link to post
Share on other sites

  • 4 weeks later...
  • 5 months later...

Hello,
Though I am more familiar (experienced) in PIC, hence Arduino, the Raspberry Pi vs Arduino is a question of what you have in hand and how much time do you have at your disposal.
There is a good example of model of controlled railway, including hardware, coding and connection steps.

http://www.penguintutor.com/projects/modelrailwayautomation

After several personal trials, I have went through it as well.
 

Link to post
Share on other sites

  • 2 months later...
  • RMweb Premium

I have just acquired a OV5642 camera module and am going to see what the Pico video output is like.

 

There is more support now and the MagPi mag (download for free - I have donated!) has had several Pico special sections.

  • Informative/Useful 2
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...