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 : RP2040 Geek
Page 2 of 3 | |||||
Author | Message | ||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
Got to understand adc pin and pwm pin if available. SETPIN GP29, AIn adc open 500000,1 is ok but not working right Edited 2024-02-07 06:34 by stanleyella |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4233 |
Maybe gp26 is adc1 Gp29 is adc3 ??? Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
Only ADC2 (GP28) and ADC3 (GP29) are brought out, by the looks of things. You can't use ADC0 (GP26) and ADC1 (GP27). Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
I got no idea how to set this up Volhout. strange errors. how to clear pins? RUN [9] ADC open 500000,3 Error : Invalid frequency > C:\Users\stanley555\Documents\mmbasic programs\160x80trigscopev07.bas Uploading using: 'target port\COM9:115200 s\picomite Upload started NEW > AUTOSAVE Upload completed 1 Saved 862 bytes > Time taken: 2625mS RUN [9] ADC open 50000,3 Error : Pin GP28 is not off or an ADC input > C:\Users\stanley555\Documents\mmbasic programs\160x80trigscopev07.bas Uploading using: 'target port\COM9:115200 s\picomite Upload started NEW > AUTOSAVE Upload completed 1 Saved 875 bytes > Time taken: 2673mS RUN [7] SetPin GP28,off Error : Pin 34/GP28 is reserved on startup > 'SetPin GP28,pwm1A 'this optional test signal comment out 'PWM 1,10000,50 'square wave ,this optional test signal comment out 'SetPin GP28,off dim c%,x%,samples!(480) SETPIN GP26, AIn adc open 50000,3 FRAMEBUFFER CREATE F FRAMEBUFFER LAYER L FRAMEBUFFER WRITE L line 0,mm.vres/2,mm.hres,mm.vres/2,,rgb(blue) line mm.hres/2,0,mm.hres/2,mm.vres,,rgb(blue) 'draw cross to layer L 'line 119,0,119,239,,rgb(blue) 'line 0,119,239,119,,rgb(blue) FRAMEBUFFER WRITE F do adc start samples!() 'get new samples 'trigger c%=0 do:If samples!(c%) > 0.1 then if samples!(c%+1) < 0.2 then exit do inc c%:loop while c%<160 math scale samples!(),239/3.3,samples!()'scale to 80 pixel height FRAMEBUFFER COPY L,F for x%=0 to 238 'screen width line x%,samples!(x%+c%),x%+1,samples!(x%+1+c%),,rgb(green) 'draw new sample from sample(c%) next x% FRAMEBUFFER COPY F,N loop |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
You can't use GP26 as AIN. You can't read it. ADC OPEN accepts n_channels as the number of channels. You can't use the first two as they aren't available, so set it to 3. Then you'll get GP26, GP27 and GP28. You'll have to use GP28 as the input. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
duhrrr?, so no pwm, or much else? nice display, just loaded bubble universe version. bubble burst. the 160x80 version was better imho, more normal. geek was sold as it is not the 160x80 in a case so my fault... but still could be useful... or not. |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
thanks but I get RUN [9] SetPin GP28, AIn Error : Pin 34/GP28 is reserved on startup used by lcd option list PicoMite MMBasic Version 5.08.00 OPTION SYSTEM SPI GP10,GP11,GP28 OPTION AUTORUN ON OPTION FLASH SIZE 4194304 OPTION HEARTBEAT OFF OPTION PICO OFF OPTION LCDPANEL ST7789_135, LANDSCAPE,GP8,GP12,GP9,GP25 OPTION SDCARD GP23, GP18, GP19, GP20 OPTION AUDIO GP2,GP3', ON PWM CHANNEL 1 > |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
what pins can you use? Edited 2024-02-07 09:20 by stanleyella |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
The geek has I2C/ADC as gp28 and gp29 but the manual says no?? no gp29 SETPIN sda, scl, I2C Valid pins are SDA: GP0, GP4, GP8, GP12, GP16, GP20 or GP28 SCL: GP1, GP5, GP9, GP13, GP17 or GP21 And the following command for the second channel (referred to as I2C2): SETPIN sda, scl, I2C2 Valid pins are SDA: GP2, GP6, GP10, GP14, GP18, GP22 or GP26 SCL: GP3, GP7, GP11, GP15, GP19 or GP27 |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
That board does not use the standard Pico pin assignments so you must include the first two Options. Its all explained on the previous page. Edited 2024-02-07 09:58 by phil99 |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
don't buy this unless you know what it does/doesn't the 160x80 picomite was MUCH more like a pico and display to use, imho... and a usb c socket 2 me. just worked. |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 828 |
I once created a list: Possibilities - UART connector GP4/GP5: ======================================= COM2: TX-GP4, RX-GP5 PWM2: PWM2A-GP4, PWM2B-GP5 I2C1: SDA1-GP4, SCL1-GP5 Possibilities - DEBUG connector GP2/GP3: ======================================== I2C2: SDA2-GP2, SCL2-GP3 PWM1: PWM1A-GP2, PWM1B-GP3 Possibilities - I2C/ADC connector GP28/GP29: ============================================ ADC: ADC2-GP28, ADC3-GP29 PWM: PWM6A-GP28 I2C1: SDA1-GP28 There are certainly a few more possibilities. (...I haven't tried all of these options yet...) Frank |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4233 |
Additional: GP29 is PWM6B / SCL1 GP28/GP29 can also be used as COM1 (the chip can, MMBasic may prevent this). I will test it when I get my unit. You can also combine DEBUG and UART connector to create a SPI bus. GP2 = SPI CLK GP3 = SPI TX GP4 = SPI RX GP5 can be used as CS. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
If you can't get GP29 to work then use OPTION PICO OFF to free off the pins that are normally dedicated to the Pico. The I2C/ADC connector should work fine. Make GP28 the input that you are using. You MUST specify 3 ACD channels in the ADC OPEN command, even though you can't use ADC0 and ADC1. You will probably also have to use SETPIN GP26 AIN and SETPIN GP27 AIN as well as SETPIN GP28 AIN or you'll probably get an error from ADC OPEN GP26 and GP27 are still there but they aren't connected to anything. They will read but return junk values. You'll probably have to think of this as a 3-channel scope but only plot ADC2 (GP28). Unfortunately, because ADC0 and ADC1 are also being read your maximum usable frequency will be lower. In the "round robin" automatic reading of the ADC channels you have to read ADC0 and ADC1 if you want to read ADC2 - you can't get away from that. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4233 |
Objective: So we need to add.... - ADC header (GP26/GND/GP27) - COM1 header (GP0/GND/GP1) Curious if the design would allow for both headers (volume wise) Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
It's a normal RP2040 board as far as I cab tell. Just think of it as if it's a PicoMite but with some pins chopped off. :) The headers are simply hard wired, just like a normal Pico, so all signals available on the headers are valid. Pins used internally are: GP 8, 9, 10, 11, 12, 18, 19, 20, 21, 22, 23, 25 Pins not on that list, but not appearing on the headers, go nowhere. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
Hi, seen the post about adc? If you can't get GP29 to work then use OPTION PICO OFF to free off the pins that are normally dedicated to the Pico. The I2C/ADC connector should work fine. Make GP28 the input that you are using. You MUST specify 3 ACD channels in the ADC OPEN command, even though you can't use ADC0 and ADC1. You will probably also have to use SETPIN GP26 AIN and SETPIN GP27 AIN as well as SETPIN GP28 AIN or you'll probably get an error from ADC OPEN GP26 and GP27 are still there but they aren't connected to anything. They will read but return junk values. You'll probably have to think of this as a 3-channel scope but only plot ADC2 (GP28). Unfortunately, because ADC0 and ADC1 are also being read your maximum usable frequency will be lower. In the "round robin" automatic reading of the ADC channels you have to read ADC0 and ADC1 if you want to read ADC2 - you can't get away from that. Mick Steve, not this messin with 160x80 picomite, the geek is for geeks not a useful device for most. Edited 2024-02-08 09:09 by stanleyella |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4233 |
Just Received my Geek unit... It works with the above config as expected. But ..man!.. these connectors are small, and the wires flimsy (and short). I am not sure this is a robust debugging tool. Since I hate looking at a black screen, I started out with a short program in flash slot 2 that just puts some text on the display "PicoMite V50800" indication it starts up, since there is no heartbeat LED. And then OPTION AUTORUN 2. More for another day... Volhout Edited 2024-02-09 04:48 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
NPHighview Senior Member Joined: 02/09/2020 Location: United StatesPosts: 200 |
Thanks, Volhout and Stanleyella for the guidance regarding ADC channels, PWM, and pin assignments. While thinking about those, I adapted the Life program for this device, and generalized it to figure out the screen resolution and orientation by itself. Here's the code, with tip o' the hat to Vegipete: ' Game of Life by John CONWAY. ' Unfortunately, Covid19 took John's life on April 11, 2020. His ' legacy lives on in the countless people inspired by his invention ' of the cellular automaton called the Game of Life and his other works. ' ' Written by vegipete, Apr 2020 for GFXTerm ' Modified by Steve Johnson, July 2023 for RP2040-LCD-0.96 in Landscape LCD ' Modified by Steve Johnson, Feb 2024 for any display & orientation Option DEFAULT INTEGER Const x = MM.HRes/2 ' Horizontal Center of LCD Const y = MM.VRes/2 ' Vertical Center of LCD Const top = 0 Const bot = MM.VRes-1 Const left = 0 Const right = MM.HRes-1 Const ltop = top ' Top edge of Universe display on LCD Const lleft = left ' Left edge of Universe display on LCD Const lspac = 10 ' Cell spacing on Universe display on LCD Const width = lspac-1 ' Width And Height of Cells on LCD Const height = lspac-1 Const live = RGB(Cyan) : Const dead = RGB(Gray) : Const empty = RGB(Black) Const HMax = Int(MM.HRes/lspac) Const VMax = Int(MM.VRes/lspac) Dim INTEGER i, j, count, w(HMax+1,VMax+1), Changed Do CLS RGB(Yellow) Text x, y-36, "Conway's", "CM", 3, 1, RGB(Black), RGB(Yellow) Text x, y-12, " GAME ", "CM", 3, 1, RGB(Red), RGB(Yellow) Text x, y+12, " of ", "CM", 3, 1, RGB(Red), RGB(Yellow) Text x, y+36, " LIFE ", "CM", 3, 1, RGB(Red), RGB(Yellow) Math SET 0, w() ' clear the world to start Pause 4000 : CLS : Randomize Timer RandLife : Penta 3, 6 LCDLife ' Display the Universe Changed = 1 Do While Changed i = i+1 : Changed = 0 CONWAYLife ' Calculate the next generation LCDLife ' Display the Universe Loop Loop End Sub Heavy ' Seed life with a Heavyweight Spaceship w(16, 9)=1 : w(16,11)=1 w(17, 8)=1 w(18, 8)=1 : w(18,12)=1 w(19, 8)=1 : w(19,12)=1 w(20, 8)=1 w(21, 8)=1 : w(21,11)=1 w(22, 8)=1 : w(22, 9)=1 : w(22,10)=1 End Sub Sub Penta h, v ' Seed life with a Pentadecathlon (period 15) w(h ,v)=1 : w(h ,v+1)=1 : w(h ,v+2)=1 w(h+ 1,v+1)=1 w(h+ 2,v+1)=1 w(h+ 3,v)=1 : w(h+ 3,v+1)=1 : w(h+ 3,v+2)=1 w(h+ 5,v)=1 : w(h+ 5,v+1)=1 : w(h+ 5,v+2)=1 w(h+ 6,v)=1 : w(h+ 6,v+1)=1 : w(h+ 6,v+2)=1 w(h+ 8,v)=1 : w(h+ 8,v+1)=1 : w(h+ 8,v+2)=1 w(h+ 9,v+1)=1 w(h+10,v+1)=1 w(h+11,v)=1 : w(h+11,v+1)=1 : w(h+11,v+2)=1 End Sub Sub SeedLife ' Seed the world with a simple pattern w( 9,10) = 1 : w(10,10) = 1 : w(11,10) = 1 w( 9,11) = 1 : w(11,11) = 1 w( 9,12) = 1 : w(11,12) = 1 w(10,13) = 1 w( 7,14) = 1 : w( 9,14) = 1 : w(10,14) = 3: w(11,14) = 1 w( 8,15) = 1 : w(10,15) = 1 : w(12,15) = 1 w(10,16) = 1 : w(13,16) = 1 w( 9,17) = 1 : w(11,17) = 1 w( 9,18) = 1 : w(11,18) = 1 End Sub Sub RandLife ' Seed Life with a random pattern Local i For i = 1 To HMax*VMax/7 w((1+Rnd*HMax),(1+Rnd*VMax)) = 1 Next i End Sub Sub CONWAYLife ' Calculate a new generation of life Local integer i, j, count Math SCALE w(), 2, w() ' shift left & clear new generation ' Wrap corners & edges To simplify neighbor count evaluation w(0,0)=w(HMax,VMax) : w(HMax+1,VMax+1)=w(1, 1) w(0,VMax+1)=w(HMax,1) : w(HMax+1, 0)=w(1,VMax) For i = 1 To VMax ' wrap the edges w(0,i)=w(HMax,i) : w(HMax+1,i)=w(1,i) Next i For j = 1 To HMax w(j,0)=w(j,VMax) : w(j,VMax+1)=w(j,1) Next j ' calculate new generation For i = 1 To HMax For j = 1 To VMax count = Neighbors(i,j) If count=3 Then Inc w(i,j) If count=2 Then If w(i,j) And 2) = 2 Then Inc w(i,j) EndIf Next j Next i End Sub Function Neighbors(x,y) ' return number of neighbors around given point Local count = 0 ' good candidate for C subroutine. count = (w(x-1,y-1) And 2) + (w(x+0,y-1) And 2) + (w(x+1,y-1) And 2) count = count + (w(x-1,y+0) And 2) + (w(x+1,y+0) And 2) + (w(x-1,y+1) And 2) count = count + (w(x+0,y+1) And 2) + (w(x+1,y+1) And 2) Neighbors = count>>1 ' Previous lines are bitwise ANDs, not Logical :-( End Function Sub LCDLife ' display the current world on LCD. Indicate if changes occurring Local integer i,j, xcoord, ycoord xcoord = lleft ' Left side of Universe display on LCD screen For i = 1 To HMax ycoord = ltop ' top edge of Universe display on LCD screen For j = 1 To VMax Select Case (w(i,j) And 3) ' faster than IF..THEN..ELSE..ENDIF Case 1: Box xcoord, ycoord, width, height, 1, live, live : Changed = 1 Case 2: Box xcoord, ycoord, width, height, 1, dead, empty : Changed = 1 End Select Inc ycoord, lspac Next j Inc xcoord, lspac Next i End Sub This doesn't detect cycles, but that's on my to-do list. Edited 2024-02-12 09:38 by NPHighview Live in the Future. It's Just Starting Now! |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4233 |
Works nice !! I like the fact that you can see what cells in the grid where alive once, and what cells that where never alive.. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Page 2 of 3 |
Print this page |