Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:50 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Bug in RGB() command?

Author Message
George H
Newbie

Joined: 03/07/2020
Location: United States
Posts: 24
Posted: 01:27am 21 Aug 2023
Copy link to clipboard 
Print this post

PicoMite MMBasic Version 5.07.08b9
Option Colourcode On

It seems the computed values for red and green are swapped. Or could it be board specific? RGB(255, 0, 0) lights the led green.  RGB(0,255,0) lights it red.  

Using the Waveshare RP2040-Matrix board.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2136
Posted: 02:15am 21 Aug 2023
Copy link to clipboard 
Print this post

No problem on any of my displays, must  board specific.
What display controller chip does the LCD use?
Check the manual to see if there are special settings for it.
 
George H
Newbie

Joined: 03/07/2020
Location: United States
Posts: 24
Posted: 02:32am 21 Aug 2023
Copy link to clipboard 
Print this post

It's the WS2812.  With a 1-wire interface, not sure how it could be wired wrong - I can work around it but it's strange.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 04:17am 21 Aug 2023
Copy link to clipboard 
Print this post

5.07.08b11
My WS2812 gives the correct colours. A single chip.
Mine needs type O and if I use type B, all I get is white.

It also works correctly on much earlier firmware.

Try both WS2812 types.

Jim
VK7JH
MMedit   MMBasic Help
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 07:08am 21 Aug 2023
Copy link to clipboard 
Print this post

Of course, there's no guarantee that they have used the same version of the WS2812 that we know. There may be other variations.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9126
Posted: 08:40am 21 Aug 2023
Copy link to clipboard 
Print this post

This is a classic symptom of incorrect WS2812 timing and nothing to do with the RGB command. As others have said try the different variants and if nothing works then your LED is perhaps faulty of a new variant that the firmware doesn't understand
 
George H
Newbie

Joined: 03/07/2020
Location: United States
Posts: 24
Posted: 05:42pm 21 Aug 2023
Copy link to clipboard 
Print this post

Tried both types (B and O) and same behavior. Found another WS2812 and behavior is normal so I guess it's these little Waveshare boards.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9126
Posted: 06:31pm 21 Aug 2023
Copy link to clipboard 
Print this post

  Quote  so I guess it's these little Waveshare boards.


Which board? Please post link. Did you try "S"?
Edited 2023-08-22 04:32 by matherp
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 06:34pm 21 Aug 2023
Copy link to clipboard 
Print this post

This one:  LINK

SCHEMATIC

Says it's a WS2812B, but has a mosfet level shifter.


I don't know when the change happened, but at one point the reset pulse time was lengthened from >50us to >280us. That breaks things sometimes. Link

.
Edited 2023-08-22 04:49 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
barewires
Newbie

Joined: 13/04/2015
Location: United Kingdom
Posts: 30
Posted: 07:27am 22 Aug 2023
Copy link to clipboard 
Print this post

[code]
#waveshare rp2040-zero-GRBblack-blink.py
#MicroPython v1.19.1-879-g294098d28 on 2023-02-20; Raspberry Pi Pico W with RP2040
#by chatgpt and RS 25022023
import machine
import neopixel
import utime

# set up neopixel LED
NUM_LEDS = 1
np = neopixel.NeoPixel(machine.Pin(16), NUM_LEDS, bpp=3)
green = (128,0,0,255)
red = (0,128,0)
blue = (0,0,128)
black = (0,0,0)

def doneopixel(color):
   np[0] = color  # set LED color
   np.write()     # update LED
   utime.sleep(.1)
 
# main loop
while True:
   # generate RGB color
   color = red
   doneopixel(color)
   color = green
   doneopixel(color)
   color = blue
   doneopixel(color)
   color = black
   doneopixel(color)
   utime.sleep(1.1)
[/code]
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 07:45am 22 Aug 2023
Copy link to clipboard 
Print this post

This is about as simple a test as you can get to identify the LED colours in normal MMBasic. It should work aas expected with standard WS2812B and WS2812 (by changing the B to O). I've not tested this, by the way.


do
 bitbang ws2812 b, gp12, 1, &hCC0000 'red
 pause 500
 bitbang ws2812 b, gp12, 1, &h00CC00 'green
 pause 500
 bitbang ws2812 b, gp12, 1, &h0000CC 'blue
 pause 500
loop


This data sheet indicates that the display order is GRB, not RGB. Note that this data sheet predates the change to >280ms reset time (LINK). MMBasic appears to swap R and G values to make the command compatible with the RGB(rr,gg,bb) format.

(I thought this site was interesting.)
Edited 2023-08-22 18:16 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9126
Posted: 08:28am 22 Aug 2023
Copy link to clipboard 
Print this post

Looks like there is a new variant of the WS2812B, I'll increase the reset pulse in the next beta
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 08:34am 22 Aug 2023
Copy link to clipboard 
Print this post

I've not managed to find a newer data sheet. I found a link, but it's dead.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
George H
Newbie

Joined: 03/07/2020
Location: United States
Posts: 24
Posted: 07:51pm 22 Aug 2023
Copy link to clipboard 
Print this post

Yes, that's the board I'm using, sorry.  They were posted up here a while back.  Thanks for sleuthing the details, Mick.
 
George H
Newbie

Joined: 03/07/2020
Location: United States
Posts: 24
Posted: 07:52pm 22 Aug 2023
Copy link to clipboard 
Print this post

Thanks Peter, when the next release is available I'll give it a try and report back.

Edit: tried 'S', no change.
Edited 2023-08-23 09:21 by George H
 
George H
Newbie

Joined: 03/07/2020
Location: United States
Posts: 24
Posted: 11:28pm 22 Aug 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  This is about as simple a test as you can get to identify the LED colours in normal MMBasic. It should work aas expected with standard WS2812B and WS2812 (by changing the B to O). I've not tested this, by the way.


do
 bitbang ws2812 b, gp12, 1, &hCC0000 'red
 pause 500
 bitbang ws2812 b, gp12, 1, &h00CC00 'green
 pause 500
 bitbang ws2812 b, gp12, 1, &h0000CC 'blue
 pause 500
loop




Mick that test gives the same green/red swapped behavior as before.  Also, seems to make no difference whether I use O, S, or B.  

I can report that the little board overclocks nicely to 376Mhz.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 06:56am 23 Aug 2023
Copy link to clipboard 
Print this post

T thought it would as it's using the MMBasic RGB translation rather than controlling the WS2812 directly, which would, apparently, use GRB according to the data sheet.

It seems odd that using a "conventional" WS2812B under MMBasic is fine yet this board isn't. The WS2812B's RGB order hasn't changed AFAIK so I can only think that it's a timing issue with those particular devices.
.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024