![]() |
Forum Index : Microcontroller and PC projects : hardware vga thing
![]() ![]() |
|||||
Author | Message | ||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
@lizby (or lyizb ![]() Pretty much half the speed of the PicoMite (standard clocking). I would call that very respectable ![]() Many thanks. I read somewhere that cicciocb is now working on optimizing for speed ![]() Craig |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
On a ESP32 with Annex32 or a MMBasic device? If it's the latter, you need the benchmark listing that's a couple of posts prior. Craig |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
I got to change this carp to mmbasic. Why not? a good way of learning another basic. duh.. do you know what I mean... doddle?? ;fullwave stepper V53L0X robot #chip mega328p,16 #option Explicit dir portc.0 out ;servo dir portd.0 out:dir portd.1 out:dir portd.2 out:dir portd.3 out ;left motor dir portd.4 out:dir portd.5 out:dir portd.6 out:dir portd.7 out ;right motor ;set up V53L0X #define HI2C_DATA PORTC.5 ;sda portc.4 for nano portc.5 for uno #define HI2C_CLOCK PORTC.4 ;scl portc.5 for nano portc.4 for uno #define HI2C_BAUD_RATE 400 HI2CMode Master ; ;v53l0x software restart HI2CStart HI2CSend(0x52) HI2CSend(0x89) HI2CSend(0x01) HI2CStop wait 200 ms ; dim l_mot_pos,r_mot_pos,l_mot_port,r_mot_port as byte dim l_mot_dir,r_mot_dir as byte dim servopos as Word dim servodir,distance_lo,distance_hi,mindist,last_turn as Byte ; #define distance distance_hi*256 + distance_lo ;v53l0x distance #define forward 1 ;| #define reverse 255 ;|--motor direction #define stop 0 ;| #define servopin portc.0 #define wasleft 1 #define wasright 0 ; last_turn = random and 1 ;0 or 1 servopos=1500 ;1.5ms servo mid position servodir=1 ;servo rotation direction mindist=200 ;minimum distance before avoiding l_mot_pos=1:r_mot_pos=1 l_mot_dir=forward:r_mot_dir=forward ;----------- ;set up interrupts dim mills as byte : mills = 0 On Interrupt Timer0Match1 Call isr Dim OCR0 AS byte alias OCR0A Dim TCCR0 AS byte alias TCCR0B WGM01 = 1 OCR0 = 124 ;2ms TCCR0 = 0x28 TCCR0 = TCCR0 or 0x04 ;----------- do ;main program ;check for objects and avoid getdistance ;any object too close? if distance <> 20 then ;20 means out of range so skip distance test ; ;distance to obstacle test if servopos > 1300 then ;not pointing right if servopos < 1700 then ;not pointing left mindist = 200 ;pointing forward min distance end if else mindist = 250 ; left and right min distance end if ; if distance < mindist then ;object close l_mot_dir=stop:r_mot_dir=stop ;stop motors ; if servopos > 1700 then turnright_until_clear ;object left last_turn = wasright else if servopos < 1300 then turnleft_until_clear ;object right last_turn = wasleft else ;obstacle forward l_mot_dir=reverse : r_mot_dir=reverse : wait 500 ms ;reverse 500ms if last_turn = wasright then ;turn right again servodir=1 turnright_until_clear else ;turn left again servodir=0 turnleft_until_clear end if end if l_mot_dir=forward:r_mot_dir=forward ;go forward end if end if ; ;rotate servo left-right if servodir = 1 then servopos = servopos +80 if servopos = 2220 then servodir = 0 end if else servopos = servopos - 80 if servopos = 780 then servodir = 1 end if end if ; pulseout servopin,servopos us wait 30 ms 'to allow servo to move slower and not overheat and getdistance to work loop ;end of main ;------------------- sub isr motors ;every 2ms mills = mills + 2 if mills = 20 then mills=0 : servo ;every 20ms end sub ;-------------------- sub getdistance HI2CStart ;Sys V53L0X Range Start HI2CSend(0x52) HI2CSend(0x00) HI2CSend(0x01) HI2CStop HI2CStart ;read distance HI2CSend(0x52) HI2CSend(0x1e) HI2CReStart HI2CSend(0x53) ;set the read flag HI2CReceive(distance_hi) HI2CReceive(distance_lo, NACK) ;read one byte and conclude HI2CStop end sub ;------------------- sub turnleft_until_clear do l_mot_dir=reverse:r_mot_dir=forward ;rotate anti clockwise wait 20 ms l_mot_dir=stop:r_mot_dir=stop getdistance loop until distance > mindist ;rotate left until clear end sub ;------------------- sub turnright_until_clear do l_mot_dir=forward:r_mot_dir=reverse ;rotate clockwise wait 20 ms l_mot_dir=stop:r_mot_dir=stop getdistance loop until distance > mindist ;rotate right until clear end sub ;------------------- sub motors ;left motor if l_mot_dir<>stop then if l_mot_dir=forward then l_mot_pos++ if l_mot_pos=5 then l_mot_pos=1 else l_mot_pos--- if l_mot_pos=0 then l_mot_pos=4 end if readtable l_mot_phase,l_mot_pos,l_mot_port else l_mot_port=0b11110000 end if ;right motor if r_mot_dir<>stop then if r_mot_dir=forward then r_mot_pos++ if r_mot_pos=5 then r_mot_pos=1 else r_mot_pos--- if r_mot_pos=0 then r_mot_pos=4 end if readtable r_mot_phase,r_mot_pos,r_mot_port else r_mot_port=0b00001111 end if ;out left right phase to port portd=l_mot_port and r_mot_port end sub ; table l_mot_phase 0b11110011,0b11110110,0b11111100,0b11111001 end table table r_mot_phase 0b00111111,0b01101111,0b11001111,0b10011111 end table ;------------------- sub servo pulseout servopin,servopos us end sub it looks like https://www.youtube.com/watch?v=s5-5DNa36jk a peace cake. It's a good range finder for a metre. |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
I said before that it is better to start afresh.. I'll do the vlox mmbasic style if I can. It is good. |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
;fullwave stepper V53L0X robot #chip mega328p,16 #option Explicit dir portc.0 out ;servo dir portd.0 out:dir portd.1 out:dir portd.2 out:dir portd.3 out ;left motor dir portd.4 out:dir portd.5 out:dir portd.6 out:dir portd.7 out ;right motor ;set up V53L0X #define HI2C_DATA PORTC.5 ;sda portc.4 for nano portc.5 for uno #define HI2C_CLOCK PORTC.4 ;scl portc.5 for nano portc.4 for uno #define HI2C_BAUD_RATE 400 HI2CMode Master ; ;v53l0x software restart HI2CStart HI2CSend(0x52) HI2CSend(0x89) HI2CSend(0x01) HI2CStop wait 200 ms ; dim l_mot_pos,r_mot_pos,l_mot_port,r_mot_port as byte dim l_mot_dir,r_mot_dir as byte dim servopos as Word dim servodir,distance_lo,distance_hi,mindist,last_turn as Byte ; #define distance distance_hi*256 + distance_lo ;v53l0x distance #define forward 1 ;| #define reverse 255 ;|--motor direction #define stop 0 ;| #define servopin portc.0 #define wasleft 1 #define wasright 0 ; last_turn = random and 1 ;0 or 1 servopos=1500 ;1.5ms servo mid position servodir=1 ;servo rotation direction mindist=200 ;minimum distance before avoiding l_mot_pos=1:r_mot_pos=1 l_mot_dir=forward:r_mot_dir=forward ;----------- ;set up interrupts dim mills as byte : mills = 0 On Interrupt Timer0Match1 Call isr Dim OCR0 AS byte alias OCR0A Dim TCCR0 AS byte alias TCCR0B WGM01 = 1 OCR0 = 124 ;2ms TCCR0 = 0x28 TCCR0 = TCCR0 or 0x04 ;----------- do ;main program ;check for objects and avoid getdistance ;any object too close? if distance <> 20 then ;20 means out of range so skip distance test ; ;distance to obstacle test if servopos > 1300 then ;not pointing right if servopos < 1700 then ;not pointing left mindist = 200 ;pointing forward min distance end if else mindist = 250 ; left and right min distance end if ; if distance < mindist then ;object close l_mot_dir=stop:r_mot_dir=stop ;stop motors ; if servopos > 1700 then turnright_until_clear ;object left last_turn = wasright else if servopos < 1300 then turnleft_until_clear ;object right last_turn = wasleft else ;obstacle forward l_mot_dir=reverse : r_mot_dir=reverse : wait 500 ms ;reverse 500ms if last_turn = wasright then ;turn right again servodir=1 turnright_until_clear else ;turn left again servodir=0 turnleft_until_clear end if end if l_mot_dir=forward:r_mot_dir=forward ;go forward end if end if ; ;rotate servo left-right if servodir = 1 then servopos = servopos +80 if servopos = 2220 then servodir = 0 end if else servopos = servopos - 80 if servopos = 780 then servodir = 1 end if end if ; pulseout servopin,servopos us wait 30 ms 'to allow servo to move slower and not overheat and getdistance to work loop ;end of main ;------------------- sub isr motors ;every 2ms mills = mills + 2 if mills = 20 then mills=0 : servo ;every 20ms end sub ;-------------------- sub getdistance HI2CStart ;Sys V53L0X Range Start HI2CSend(0x52) HI2CSend(0x00) HI2CSend(0x01) HI2CStop HI2CStart ;read distance HI2CSend(0x52) HI2CSend(0x1e) HI2CReStart HI2CSend(0x53) ;set the read flag HI2CReceive(distance_hi) HI2CReceive(distance_lo, NACK) ;read one byte and conclude HI2CStop end sub ;------------------- sub turnleft_until_clear do l_mot_dir=reverse:r_mot_dir=forward ;rotate anti clockwise wait 20 ms l_mot_dir=stop:r_mot_dir=stop getdistance loop until distance > mindist ;rotate left until clear end sub ;------------------- sub turnright_until_clear do l_mot_dir=forward:r_mot_dir=reverse ;rotate clockwise wait 20 ms l_mot_dir=stop:r_mot_dir=stop getdistance loop until distance > mindist ;rotate right until clear end sub ;------------------- sub motors ;left motor if l_mot_dir<>stop then if l_mot_dir=forward then l_mot_pos++ if l_mot_pos=5 then l_mot_pos=1 else l_mot_pos--- if l_mot_pos=0 then l_mot_pos=4 end if readtable l_mot_phase,l_mot_pos,l_mot_port else l_mot_port=0b11110000 end if ;right motor if r_mot_dir<>stop then if r_mot_dir=forward then r_mot_pos++ if r_mot_pos=5 then r_mot_pos=1 else r_mot_pos--- if r_mot_pos=0 then r_mot_pos=4 end if readtable r_mot_phase,r_mot_pos,r_mot_port else r_mot_port=0b00001111 end if ;out left right phase to port portd=l_mot_port and r_mot_port end sub ; table l_mot_phase 0b11110011,0b11110110,0b11111100,0b11111001 end table table r_mot_phase 0b00111111,0b01101111,0b11001111,0b10011111 end table ;------------------- sub servo pulseout servopin,servopos us end sub Code is easier to differentiate from the message when using the code button at the top. Simply paste or type between: Shortcut (middle button): |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
I did not think it would work with other code.. so it is just text? code code My point was other basic is so different. I played with lots of devices and want to share but there is the syntax and variables and everything difference. So much for BASIC being universal... but remember computers in the '80's. Could you jump between a zx specrtum,dragon32,c64,amiga,trs80,atari st,vic20,bbc micro? It is the same now for micro controllers but less and different choice. For me it's learn mmbasic and use old code as a guide maybe. Converting is not efficient imho. |
||||
andreas![]() Senior Member ![]() Joined: 07/12/2020 Location: GermanyPosts: 226 |
yes the vt100 terminal shows it in the startup message. below the terminal message follows the latest PicoMite message version 5.07.05b18 ![]() The Pico gets its power through the serial connection and the terminal gets its power from the USB cable running to my PC. To get the serial connection working one has to issue OPTION SERIAL CONSOLE GP0 GP1 when GP0 and GP1 are used to connect to the terminal. I have connected terminal GND to pin 3 of the pico and terminal 3.3v to VSYS (pin 39) of the pico. ![]() ![]() I wrote a tiny vt100 program to draw boxes using ESC sequences and it works Clearscreen For x1 = 1 To 400 drawbox x1,10,400,400 Next x1 End Sub drawbox(x1,y1,x2,y2) Print Chr$(27)+"[Z2;"+Str$(x1)+";"+Str$(y1)+";"+Str$(x2)+";"+Str$(y2)+"Z" Pause 30 Clearscreen End Sub Sub Clearscreen Print Chr$(27)+"[2J"+Chr$(27)+"[H" End Sub -andreas |
||||
pwillard Guru ![]() Joined: 07/06/2022 Location: United StatesPosts: 313 |
The short answer: "no, you could not." Most *flavors* of Basic back in the early home computer era would have many features that were unique to that particular design... so while the common features of BASIC were there (IF THEN ELSE STRING Handling, PRINT, ETC) when it came to how things were displayed on the screen... nearly every device would have special BASIC commands added to make use of the Graphics Controller in that particular system. So other than entering programs from DAVID AHL BOOKS (Which purposely used "generic" basic most of the time), you would have to try to convert the graphic specialties of each machine. In most cases, it was non-trivial. Back then, most people would gather as "birds of a feather" in early computer clubs based on specific computers. In any given small city, you could find an APPLE Club. a TRS80 Club, a Color Computer Club, S100 Clubs, Commodore Clubs, etc. Edited 2022-09-02 09:59 by pwillard |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Not true. The MMBASIC port based on the Raspberry Pi Zero and the standard Raspberry Pi boards have been dropped for that reason, cos they keep changing too many things at the OS level, that breaks the code development of MMBASIC on those boards. But the Pico module is known hardware, with a known way to load a firmware file, and no other things in the background(such as a controlling OS) that can affect or otherwise screw with the development of MMBASIC on that hardware, so the PicoMite is a port that will be supported long-term moving forward I would expect at this point. The Pico module or the RP2040 chip itself are widely available and cheap despite the chip shortages in other areas, so I think you will see even MORE work and development on the PicoMite ports cos of that. ![]() ![]() It is VERY easy to feel overwhelmed by it all if you are a newbie just starting to learn the language, but like any other language - computer or verbal - it is very difficult at the start, but the more you keep at it, the easier it becomes. Speaking for myself as someone who was totally bewildered by MMBASIC when I first started with it, it has been very worthwhile to learn MMBASIC. As far as I am concerned, anyway. The CMM2 and MM+ series with the GUI graphics were a further challenge, so I would most certainly recommend that you DON'T touch the advanced GUI stuff right now, till you get more familiar with MMBASIC at its core. Good luck, don't loose hope or interest, and there are plenty of members here who will be happy to help with anything you ask. All newbie questions are welcome. Smoke makes things work. When the smoke gets out, it stops! |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
I did not know there was rpi 1,2,3,4,400 dev for mmbasic. It would have been popular. I got freebasic built but not geany setup as editor or wiringpi working on a rpi400. I got fb to build linux gcb but command line and I do not like command line or terminals which is a downer using linux. It was just a challenge as the win version is so easy. Uses ms virtual studio now. I thought mmbasic was easy to learn. My problem was the terminal editor and not setting the com port in mmedit which I used instead. I use the NON vga version as I like the lcd support. I got 3 picomites so no intention of giving up:) I got a feeling there will be more picomite users. Cheap hardware and free software and a helpful forum. Hobbyists dream. cheers, stan ps I think I have used the advanced gui as for lcd if that is blit and gauge. Edited 2022-09-03 06:49 by stanleyella |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
I got to convert this to mmbasic the HI2C is just using hardware i2c pins but will be interesting. Nice device. ;set up V53L0X #define HI2C_DATA PORTC.5 ;sda portc.4 for nano portc.5 for uno #define HI2C_CLOCK PORTC.4 ;scl portc.5 for nano portc.4 for uno #define HI2C_BAUD_RATE 400 HI2CMode Master ; ;v53l0x software restart HI2CStart HI2CSend(0x52) HI2CSend(0x89) HI2CSend(0x01) HI2CStop wait 200 ms sub getdistance HI2CStart ;Sys V53L0X Range Start HI2CSend(0x52) HI2CSend(0x00) HI2CSend(0x01) HI2CStop HI2CStart ;read distance HI2CSend(0x52) HI2CSend(0x1e) HI2CReStart HI2CSend(0x53) ;set the read flag HI2CReceive(distance_hi) HI2CReceive(distance_lo, NACK) ;read one byte and conclude HI2CStop end sub /CODE] Edited 2022-09-03 07:35 by stanleyella |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |