Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:48 25 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 : CGCOLORMAX2-B to Sherline CNC Controller for milling machine

     Page 5 of 5    
Author Message
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 857
Posted: 04:08pm 17 Aug 2024
Copy link to clipboard 
Print this post

Allie

Please post the encoder details. Pretty sure we need to level shift from 5v and there's a possibility that we have differential signals. All easy to accommodate  
 
allie
Newbie

Joined: 06/10/2018
Location: Canada
Posts: 33
Posted: 04:23pm 17 Aug 2024
Copy link to clipboard 
Print this post

  JohnS said  
  allie said  What does Picomite PIO mean.

Regards Allie

It's the PICO chip (*) which has both a (dual ARM-core) CPU and multiple state machines (each known as a PIO).

MMBasic running on the ARM core(s) is referred to as Picomite.

You can run things at the same time on each PIO state machine, without degrading the ARM cores.

(*) now available in more than one kind, RP2040 / RP2350 / etc

John


My board is a Raspberry PI PICO (2020) with the CPU RP2-B1  21/16
                                                    PVRW 57 . 00  chip
I don't know what firmware it came with but can I reload it with the MMBASIC firmware.
It has a BOOT SEL button on the board. It came from WAVESHARE and it's a basic kit with breadboard, wires, switches, leds, and other parts.

Regards Allie
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6781
Posted: 04:56pm 17 Aug 2024
Copy link to clipboard 
Print this post

That sounds like a normal Pico. Can you provide a link to the board and I'll let you know?

The RP2040 doesn't actually have that number on the chip, so it can be a little confusing. :)  What you say sounds right though.

.
Edited 2024-08-18 03:05 by Mixtel90
Mick

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

Guru

Joined: 31/03/2022
Location: United States
Posts: 463
Posted: 09:15pm 17 Aug 2024
Copy link to clipboard 
Print this post

  allie said  

The reason I want to use the SHERLINE Controllers is that they are stand alone programmable units with there own keyboard. they also have a different mode to be able to interface with another microcontroller (in my case the CMM2Gen2) for step and direction input.
The Sherline Controllers are very easy to program. Only have to input the inch's and thousand's of an inch. ie(05.020) is 5 inch's and 20 thousandth of an inch.
In stand alone programmable mode you can program 2 different programs with up to 40 different movements in each program. You can also interface two controllers together one for X AXIS and one for Y AXIS. When the X AXIS is finished its movement, it tells the Y axis to do it's movement. They can do this until the 40 different movements are completed.
Regards Allie


Sorry it took so long to get back but that very close to What I'm Trying to build, but I'm trying to build something Modular that I can build up like Legos for several different Machines like my surface Grinder or an INDEXER ON MY DRILL PRESS FOR ENGINE TURNING (JEWELING)
I may be Vulgar, but , while I'm poor, I'm Industrious, Honest,  and trustworthy! I Know my Place
 
allie
Newbie

Joined: 06/10/2018
Location: Canada
Posts: 33
Posted: 09:52pm 18 Aug 2024
Copy link to clipboard 
Print this post

  Mixtel90 said  That sounds like a normal Pico. Can you provide a link to the board and I'll let you know?

The RP2040 doesn't actually have that number on the chip, so it can be a little confusing. :)  What you say sounds right though.

.


I'm not sure how to do a link yet, I'll have to try and learn how.
There is the same one that I have in a kit on Amazon.ca called Freenove Ultimate Starter Kit for Raspberry Pi Pico. When scrolled over the picture it enlarged big enough to see the markings on the CPU and its the same as the board I have.
I tried to change the firmware that came on the one I have. I downloaded the MMBASIC firmware from Geoff's site to put on the Pico but I couldn't get it to open on my windows laptop. I checked the internet, and I think I need to download a program to open the uf2 file.

Regards Allie
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 857
Posted: 10:03pm 18 Aug 2024
Copy link to clipboard 
Print this post

Allie

With the Pico disconnected, press and hold the reset button while you connect the Pico. The Pico will appear as a new drive in Windows. Copy and paste the uf2 file to the "new drive". The firmware will load automagically    
 
allie
Newbie

Joined: 06/10/2018
Location: Canada
Posts: 33
Posted: 10:29pm 18 Aug 2024
Copy link to clipboard 
Print this post

  PhenixRising said  Allie

Please post the encoder details. Pretty sure we need to level shift from 5v and there's a possibility that we have differential signals. All easy to accommodate  


Yes I'll have to level shift. I have one that shifts from 5v to 3.3 as long as it can handle the speed.




Hope this helps
Regards Allie
 
allie
Newbie

Joined: 06/10/2018
Location: Canada
Posts: 33
Posted: 03:02am 19 Aug 2024
Copy link to clipboard 
Print this post

I finally got the firmware for MMBASIC loaded in the Pi Pico. It seems to work good with Teraterm terminal. I guess now I can refer to it as a Picomite.

The Pico CPU is the 2040 chip with only two state machines. Will I need the other CPU with three state machines for the 3 AXIS on the mill to count the encoder pulses.

Regards Allie
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 857
Posted: 05:13am 19 Aug 2024
Copy link to clipboard 
Print this post

This code will handle 4 encoders on the RP2040 Picomite


  Quote  'Quadrature multichannel decoder for PicoMite using PIO

'this is a 4 channel quadrature decoder for MMBasic V5.08.00 or newer
'running on a PicoMite or PicoMiteVGA usinf PIO 1

'Original PIO source: https://github.com/p-o-l-e/quadrature-decoder

'30-4-2024  Volhout



'system initialisation ---------------------------------------------------------

'program PIO 1
program_PIO 'program the code in PIO 1

'quadrature decoders generic settings
PIO_f%=63e6                            'frequency = 63MHz
PIO_s%=0                               'shift register (shift in left)
PIO_e%=PIO(execctrl gp0,wrp_tgt,wrap)  'start and stop of the loop

'start quadrature decoders (uncomment the needed decoders)
start_sm0 : sm0=1       'start decoder on GP0 and GP1
'start_sm1 : sm1=1       'start decoder on GP2 and GP3
'start_sm2 : sm2=1       'start decoder on GP4 and GP5
'start_sm3 : sm3=1       'start decoder on GP26 and GP27



'main MMBasic code -------------------------------------------------------------

'this code is just a demo that shows the position of the quadrature decoders
'the selected decoder positions are printed on the console
'type "r" to reset the decoders to 0

'main loop
do
  a$=inkey$                                     'just for control
 
  'get the data from the fifo and print
  if sm0 then print str$(read_fifo(0),12,0);    'get data from decoder
  if sm1 then print str$(read_fifo(1),12,0);    'get data from decoder
  if sm2 then print str$(read_fifo(2),12,0);    'get data from decoder
  if sm3 then print str$(read_fifo(3),12,0);    'get data from decoder
  print
 
  'just some pause
  pause 100                                     'any delay needed
 
  'reset position (PIO X register) under control of keyboard
  if a$="r" then                                'press r to zero position
    if sm0 then pio execute 1,0,&hA023 '= assembly "mov X, null" (zero X reg)
    if sm1 then pio execute 1,1,&hA023 '= assembly "mov X, null" (zero X reg)
    if sm2 then pio execute 1,2,&hA023 '= assembly "mov X, null" (zero X reg)
    if sm3 then pio execute 1,3,&hA023 '= assembly "mov X, null" (zero X reg)
    a$=""
  end if
 
loop while a$=""  'exit when any key not r

end




' subroutines -------------------------------------------------------------------


'this function returns the actual count of decoder n
function read_fifo(n) as integer

local dat%(3)
pio read 1,n,4,dat%()                                   'read whole fifo
read_fifo = dat%(3)                                    'last data in fifo
if read_fifo>2147483647 then inc read_fifo,-4294967296 '2'th complement

end function


'this subroutine programs the quadrature decoder program for PIO1 into
'PIO program memory
sub program_PIO

'this is the PIO program in machine code
dim p%(7)=(&h001A00170015001A,&h0015001A001A0017,&h0017001A001A0015, &h001A00150017001A,&h4042A0404042A0C3,&hA029001A005AA0A6,&h8000A0C1A0290059,0)

'here the program is programmed in memory
pio program 1,p%()

wrap=27           'end of the program
wrp_tgt=16        'start of the program loop

end sub


'this subroutine starts state machine 0 quadrature decoder on gp0 and gp1
sub start_sm0

'uses GP0,GP1, assign pins in MMBasic
setpin gp0,pio1
setpin gp1,pio1

'assign pins in PIO
pin_sm0%=PIO(pinctrl 0,0,0,gp0)

'configure and start PIO
pio init machine 1,0,PIO_f%,pin_sm0%,PIO_e%,PIO_s%,wrp_tgt
pio start 1,0

end sub


'this subroutine starts state machine 1 quadrature decoder on gp2 and gp3
sub start_sm1

'uses GP2,GP3, assign pins in MMBasic
setpin gp2,pio1
setpin gp3,pio1

'assign pins in PIO
pin_sm1%=PIO(pinctrl 0,0,0,gp2)

'configure and start PIO
pio init machine 1,1,PIO_f%,pin_sm1%,PIO_e%,PIO_s%,wrp_tgt
pio start 1,1

end sub


'this subroutine starts state machine 2 quadrature decoder on gp4 and gp5
sub start_sm2

'uses GP4,GP5, assign pins in MMBasic
setpin gp4,pio1
setpin gp5,pio1

'assign pins in PIO
pin_sm2%=PIO(pinctrl 0,0,0,gp4)

'configure and start PIO
pio init machine 1,2,PIO_f%,pin_sm2%,PIO_e%,PIO_s%,wrp_tgt
pio start 1,2

end sub


'this subroutine starts state machine 3 quadrature decoder on gp26 and gp27
sub start_sm3

'uses GP26,GP27, assign pins in MMBasic
setpin gp26,pio1
setpin gp27,pio1

'assign pins in PIO
pin_sm3%=PIO(pinctrl 0,0,0,gp26)

'configure and start PIO
pio init machine 1,3,PIO_f%,pin_sm3%,PIO_e%,PIO_s%,wrp_tgt
pio start 1,3

end sub
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 857
Posted: 06:52am 19 Aug 2024
Copy link to clipboard 
Print this post

Level shifting:

As we only need uni-direction, I use the 74HC4050 device.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 08:28am 19 Aug 2024
Copy link to clipboard 
Print this post

The "Position Sensors" circuit above will work if powered from 3.3V, then you don't need a level shifter.
If the LED current is too low at 3.3V reduce the 100Ω resistor to 68Ω or 51Ω.

Plan "B" would be to continue to have the 100Ω connected to 5V but have the 2 x 10kΩ connected to 3.3V.
 
allie
Newbie

Joined: 06/10/2018
Location: Canada
Posts: 33
Posted: 07:07pm 19 Aug 2024
Copy link to clipboard 
Print this post

  PhenixRising said  This code will handle 4 encoders on the RP2040 Picomite


  Quote  'Quadrature multichannel decoder for PicoMite using PIO

'this is a 4 channel quadrature decoder for MMBasic V5.08.00 or newer
'running on a PicoMite or PicoMiteVGA usinf PIO 1

'Original PIO source: https://github.com/p-o-l-e/quadrature-decoder

'30-4-2024  Volhout



'system initialisation ---------------------------------------------------------

'program PIO 1
program_PIO 'program the code in PIO 1

'quadrature decoders generic settings
PIO_f%=63e6                            'frequency = 63MHz
PIO_s%=0                               'shift register (shift in left)
PIO_e%=PIO(execctrl gp0,wrp_tgt,wrap)  'start and stop of the loop

'start quadrature decoders (uncomment the needed decoders)
start_sm0 : sm0=1       'start decoder on GP0 and GP1
'start_sm1 : sm1=1       'start decoder on GP2 and GP3
'start_sm2 : sm2=1       'start decoder on GP4 and GP5
'start_sm3 : sm3=1       'start decoder on GP26 and GP27



'main MMBasic code -------------------------------------------------------------

'this code is just a demo that shows the position of the quadrature decoders
'the selected decoder positions are printed on the console
'type "r" to reset the decoders to 0

'main loop
do
  a$=inkey$                                     'just for control
 
  'get the data from the fifo and print
  if sm0 then print str$(read_fifo(0),12,0);    'get data from decoder
  if sm1 then print str$(read_fifo(1),12,0);    'get data from decoder
  if sm2 then print str$(read_fifo(2),12,0);    'get data from decoder
  if sm3 then print str$(read_fifo(3),12,0);    'get data from decoder
  print
 
  'just some pause
  pause 100                                     'any delay needed
 
  'reset position (PIO X register) under control of keyboard
  if a$="r" then                                'press r to zero position
    if sm0 then pio execute 1,0,&hA023 '= assembly "mov X, null" (zero X reg)
    if sm1 then pio execute 1,1,&hA023 '= assembly "mov X, null" (zero X reg)
    if sm2 then pio execute 1,2,&hA023 '= assembly "mov X, null" (zero X reg)
    if sm3 then pio execute 1,3,&hA023 '= assembly "mov X, null" (zero X reg)
    a$=""
  end if
 
loop while a$=""  'exit when any key not r

end




' subroutines -------------------------------------------------------------------


'this function returns the actual count of decoder n
function read_fifo(n) as integer

local dat%(3)
pio read 1,n,4,dat%()                                   'read whole fifo
read_fifo = dat%(3)                                    'last data in fifo
if read_fifo>2147483647 then inc read_fifo,-4294967296 '2'th complement

end function


'this subroutine programs the quadrature decoder program for PIO1 into
'PIO program memory
sub program_PIO

'this is the PIO program in machine code
dim p%(7)=(&h001A00170015001A,&h0015001A001A0017,&h0017001A001A0015, &h001A00150017001A,&h4042A0404042A0C3,&hA029001A005AA0A6,&h8000A0C1A0290059,0)

'here the program is programmed in memory
pio program 1,p%()

wrap=27           'end of the program
wrp_tgt=16        'start of the program loop

end sub


'this subroutine starts state machine 0 quadrature decoder on gp0 and gp1
sub start_sm0

'uses GP0,GP1, assign pins in MMBasic
setpin gp0,pio1
setpin gp1,pio1

'assign pins in PIO
pin_sm0%=PIO(pinctrl 0,0,0,gp0)

'configure and start PIO
pio init machine 1,0,PIO_f%,pin_sm0%,PIO_e%,PIO_s%,wrp_tgt
pio start 1,0

end sub


'this subroutine starts state machine 1 quadrature decoder on gp2 and gp3
sub start_sm1

'uses GP2,GP3, assign pins in MMBasic
setpin gp2,pio1
setpin gp3,pio1

'assign pins in PIO
pin_sm1%=PIO(pinctrl 0,0,0,gp2)

'configure and start PIO
pio init machine 1,1,PIO_f%,pin_sm1%,PIO_e%,PIO_s%,wrp_tgt
pio start 1,1

end sub


'this subroutine starts state machine 2 quadrature decoder on gp4 and gp5
sub start_sm2

'uses GP4,GP5, assign pins in MMBasic
setpin gp4,pio1
setpin gp5,pio1

'assign pins in PIO
pin_sm2%=PIO(pinctrl 0,0,0,gp4)

'configure and start PIO
pio init machine 1,2,PIO_f%,pin_sm2%,PIO_e%,PIO_s%,wrp_tgt
pio start 1,2

end sub


'this subroutine starts state machine 3 quadrature decoder on gp26 and gp27
sub start_sm3

'uses GP26,GP27, assign pins in MMBasic
setpin gp26,pio1
setpin gp27,pio1

'assign pins in PIO
pin_sm3%=PIO(pinctrl 0,0,0,gp26)

'configure and start PIO
pio init machine 1,3,PIO_f%,pin_sm3%,PIO_e%,PIO_s%,wrp_tgt
pio start 1,3

end sub


Thanks for the info.
Do I type this into the Picomite with the teraterm terminal.

Regards Allie
 
allie
Newbie

Joined: 06/10/2018
Location: Canada
Posts: 33
Posted: 07:11pm 19 Aug 2024
Copy link to clipboard 
Print this post

  phil99 said  The "Position Sensors" circuit above will work if powered from 3.3V, then you don't need a level shifter.
If the LED current is too low at 3.3V reduce the 100Ω resistor to 68Ω or 51Ω.

Plan "B" would be to continue to have the 100Ω connected to 5V but have the 2 x 10kΩ connected to 3.3V.


Thanks for the info I'll use plan "B".

Regards Allie
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6781
Posted: 07:27pm 19 Aug 2024
Copy link to clipboard 
Print this post

Not sure which terminal you use, but you can do this using Tera Term.

new  'to clear the memory
autosave

now copy the text onto the clipboard
put the cursor into the Tera Term window and use Paste
The text is "typed" into the Pico

Press Ctrl Z

you will get the message "Saved nnnn bytes"

Your program is now loaded.

If there are missing bits or it's mangled then you need to add delays into Tera Term.
Mick

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

Joined: 06/10/2018
Location: Canada
Posts: 33
Posted: 07:33pm 19 Aug 2024
Copy link to clipboard 
Print this post

  Mixtel90 said  Not sure which terminal you use, but you can do this using Tera Term.

new  'to clear the memory
autosave

now copy the text onto the clipboard
put the cursor into the Tera Term window and use Paste
The text is "typed" into the Pico

Press Ctrl Z

you will get the message "Saved nnnn bytes"

Your program is now loaded.

If there are missing bits or it's mangled then you need to add delays into Tera Term.


Thanks, I use Tera Term.
I'll try this later
Regards
 
     Page 5 of 5    
Print this page


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

© JAQ Software 2024