Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:48 05 Jul 2025 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 : The 2350B 64 pin board for my CNC

Author Message
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1441
Posted: 08:06am 04 Jul 2025
Copy link to clipboard 
Print this post

Well first Peter I do think we need to come up with a name for this new board and big daddy does come to mind as it will be a beast in any project one takes on.

My board from Grogster has finally arrived and in 3 hours and counting it will be in my hands   as my daughter picked it up this morning and she is working and gotta say she is only 17 and has been made a manager  

Well with that out of the way a circuit board will need to be made where opto isolated outputs for the DM556 Stepper boards which will accept a 5 volt input. Now Harm did make me a file where it proved a 2040 could drive a axis   so with big daddy it should be a breeze.

Now the question as some pins on this board can handle 5 volts will they output 5 volts ?

So my idea is to use a 2040 with a 3.5" touch screen with a ILI9488 so it can be mounted on the CNC to provide live updates from big daddy and be there for jog functions etc where the 2040 can report back on any movement.

Now big daddy will be setup with a VGA screen (well no HDMI screens here) and a USB hub setup for keyboard and mouse.

Essentially 4 pins for each axis will be needed for enable, direction, step and count as for each step which can be calibrated has to be counted for accuracy as no encoders are used.

More ideas will come to mind and remember this black duck will be learning from the get go on the coding side as the grey matter comes into play also with other projects on the go aswell. Also has it has been awhile my sprint layout skills will need a touch up to suit JLCPCB.

Regards Bryan
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5035
Posted: 08:50am 04 Jul 2025
Copy link to clipboard 
Print this post

Hi Bryan,

The 2350B on the big board will output 3.3V, and (there are some that argue) should receive 3.3V at it's inputs. When your 556 stepper motor driver requires 5V you will need a level shifter. That can be a 74HCTxx gate (i.e. 74HCT04 is an inverter).. anything that can translate 3.3V to 5V and can drive a line (not one of those FET level shifters).

If you want opto coupler isolation, maybe you could look at TPS2745/TPS2345 opto couplers. These are fast, digital, can be powered from 5V to output 5V, and only require 2mA LED current (can be driven from a RP2350 pin directly with 470 ohm or 1k series resistance).

For input PhenixRising uses differential inputs (since his encoders are differential output). But in minimum you need a 5V->3.3V resitor divider and protection diodes...

Volhout

Volhout
PicomiteVGA PETSCII ROBOTS
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1441
Posted: 09:28am 04 Jul 2025
Copy link to clipboard 
Print this post

Thanks for that Harm   I can add that to the component list as I do think opto isolation will be needed as it has been done since day one of stepper motor drives.

I do have a heap of those buck converter chips that output 5 volts and ones that output 3V3 so they can be used and I just need to work out the foot print for sprint layout.

Now for getting boards made at at JLCPCB is a total new thing for me I will need a hand with with my sprint layout design to suit that.

This is going to be a huge learning curve for me as I put my mind to this as it has been close to a decade since I was involved with this stuff.

Now as you are a guru with this PIO stuff how would it go counting steps as that will be needed.

As the 556 can accept 24 volts and that is the voltage I'm using for the CNC I'm thinking it may be best to drive it from 12 volts where the datasheet says a 2.2K resistor should be put inline (the grey matter) is coming back.

Well I do have my splitting water project down pat so I can have a hydrogen torch so I can move onto this project.

Edit: Well finally got hands on my board   now the first thing to do is set the pot and program it with the latest firmware.
Edited 2025-07-04 20:47 by Bryan1
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1341
Posted: 10:36am 04 Jul 2025
Copy link to clipboard 
Print this post

I use optocouplers for 24V inputs from machine sensors.

The unlabeled devices (top left) are for two encoder inputs (I prefer two encoders per axis). They are MC3486 differential line receivers although they can be configured to handle single-ended encoders. The device between those and the RP2350 DIL is a CD4050 for 5V to 3.3V.






The MIC2981 is used for outputs. The datasheet states that it can be used for stepper-drives. It can handle a decent amount of current although I only use it to give me up to ~30mA per output with negligible load on the RP2350.
The two terminals under the MIC2981s are for external supply (up to 50V?). For me, this is typically 24V although some machines can be 5V or 12V




Bryan, I am happy to share my SL6 files although Matherp has inspired me to go to the dark side (SMD)  

My days are filled with running around the country, keeping production lines running and so I don't make the rapid progress that our resident wizards do but I hope to get some done, this weekend.
Edited 2025-07-04 20:39 by PhenixRising
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1341
Posted: 10:44am 04 Jul 2025
Copy link to clipboard 
Print this post

Harm already gave us step/direction  

'step/dir_decoder_pico_PIO_version 4

'program options
do_assemble=0        'either assemble the code, or brute force program
use_test_signal=1    'internally generate test signal

'step pulse generation for testing
if use_test_signal then
  stp_init             'init GPIO pins
  settick 10,do_step   '10ms = 100Hz step frequency
  cntr = 0            'step counter
  direction = 0       '0 = count up, 1 = count down  
else
  setpin gp0,pio1    'the STEP signal
  setpin gp1,pio1    'the DIRECTION signal
end if


'Generic defines
f= 63e6             '63 MHz PIO frequency
pio clear 1
dim dat%(4)         'array to store FIFO data


' PIO code -------------------------------------------------------------------

if do_assemble then 'assemble
 
  'header and start of the PIO code
  pio assemble 1,".program test"
  pio assemble 1,".line 0"
 
  'wait for step pulse
  pio assemble 1,"wait 0,pin,0"  'wait for GP0 to become 0
  pio assemble 1,"wait 1,pin,0"  'wait for GP0 to become 1 = rising edge STEP pulse
  pio assemble 1,"JMP pin, plus1" 'jump according state GP1 pin
 
  'The plus and minus routines, X is the actual 32 bit position counter
  pio assemble 1,"minus1:"      'label:jump here to decrement X
  pio assemble 1,"JMP X--, push_out"  'decrement X
  pio assemble 1,"JMP push_out" 'regardless X value go to push_out
  pio assemble 1,"plus1:"       'label to increment X
  pio assemble 1,"mov X, !X"    'invert X
  pio assemble 1,"JMP X--, next1" 'decrement x
  pio assemble 1,"next1:"        'label:regardless X value come here
  pio assemble 1,"mov X, !X"     'invert back
 
  'send the most recent position to FIFO
  pio assemble 1,"push_out:"      'label
  pio assemble 1,"mov ISR, X"     'move X to ISR
  pio assemble 1,"push"           'push ISR into FIFO, not blocked
 
  'jump to start of PIO program
  pio assemble 1,"JMP 0"          'jump to beginning
 
  pio assemble 1,".end program"       '50900RC4 and newerr
  'pio assemble 1,".end program list" 'needed for 50900RC3
 
else  'brute force program the same code
 
  dim p%(7)=(&h4800c520a02020,&ha0290047a0290008,&h8000a0c1,0,0,0,0,0)
  pio program 1,p%()
 
end if


'configure PIO 1 statemachine 0 (PIO 1 is free on PicoMiteVGA)
p0=pio(pinctrl 0,0,0,gp0)           'gp0 is lowest IN pin (gp0,gp1)
e0=pio(execctrl gp1,0,31)           'GP1=dir, wrap and wrap target
s0=pio(shiftctrl 0,0,0,0,0,0)       'shift IN direction is left (the 5'th '0')


'initialize PIO 1 state machine 0
pio init machine 1,0,f,p0,e0,s0,0)  'init machine @ start loop


'start the quadrature decoder PIO 1 statemachine 0
pio start 1,0



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

'main loop
do
  a$=inkey$                                     'just for control
 
  'get the data from the fifo
  pio read 1,0,5,dat%()                         'read whole fifo
  posi%=dat%(4)                                  'last data in fifo
  if posi%>2147483647 then inc posi%,-4294967296 '2'th complement
  print posi%                                    'show position
 
  '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
    pio execute 1,0,&hA023    '= assembly "mov X, null" (zero the X register)
    a$=""
  end if
 
  'set defined position in register X under control of the keyboard
  if a$="s" then
    input "desired count ";cnt%
    cnt%=cnt% and &hffffffff
    pio write 1,0,1,cnt%       'write the count cnt% in the fifo
    pio execute 1,0,&h8080  '= assemble "pull" (moves FIFO to OSR register)
    PIO execute 1,0,&hA027  '= assemble "mov X, OSR" moves the OSR value to X
    a$=""
  end if
 
loop while a$=""  'exit when any key not r

end



'test code in MMBasic that drives GP0 and GP1 according
sub stp_init
setpin gp0,dout : pin(gp0)=0  'step pin
setpin gp1,dout : pin(gp1)=0  'dir pin
end sub

sub do_step
'this rountine counts 1000 steps up, then down, etc...
inc cntr,1            'new step
pulse gp0,0.1         '1 ms step pulse
if cntr>=1000 then
  cntr = 0
  direction = 1 - direction
  pin(gp1) = direction
end if
end sub
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1441
Posted: 11:10am 04 Jul 2025
Copy link to clipboard 
Print this post

Thanks for the code mate but with this new chip GP0 isn't there as from what I've learned it reserved for the PSRAM chip.

But this code is great for testing using a 2040 which I'll do tomorrow to test each axis.

Now as I build this CNC close to 20 years ago there is no reason with you guy's we can get it going again as the last time it worked XP hung and my circuit design was ruined and with end of 32 bit that was the end of mach 3 with XP
Edited 2025-07-04 21:16 by Bryan1
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5035
Posted: 11:26am 04 Jul 2025
Copy link to clipboard 
Print this post

Hi Bryan,

When you have optocouplers at the input, you can also disconnect the LED cathode from your ground plane, and connect it directly to the ground of the system driving the input.
As it is now, the optocoupler shares input and output ground. It does not isolate.

Do you have the 64 pin footprint correct? Maybe the photo is misguiding my eyes, but it feels a bit narrow.

When you plan to use the MIC2981 to drive stepper pulse and direction, you may want to add pull-down resistors from the outputs. The MIB2981 can essentially only pull high. Not pull low. The MIC2981 is a complement to the ULN2803 (that can only pull low, not high).

Volhout
Edited 2025-07-04 21:32 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 11:37am 04 Jul 2025
Copy link to clipboard 
Print this post

The spacing between rows is 1". I tried to make it 0.9" to be the same as the 68000 processor but couldn't fit the tracks at that spacing
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1341
Posted: 11:47am 04 Jul 2025
Copy link to clipboard 
Print this post

  Volhout said  Hi Bryan,

When you have optocouplers at the input, you can also disconnect the LED cathode from your ground plane, and connect it directly to the ground of the system driving the input.
As it is now, the optocoupler shares input and output ground. It does not isolate.

Do you have the 64 pin footprint correct? Maybe the photo is misguiding my eyes, but it feels a bit narrow.

When you plan to use the MIC2981 to drive stepper pulse and direction, you may want to add pull-down resistors from the outputs. The MIB2981 can essentially only pull high. Not pull low. The MIC2981 is a complement to the ULN2803 (that can only pull low, not high).

Volhout


Not Bryan, but  

Hey thanks, Harm  

Optocouplers: In fact. What I actually intend to use is the AC-type optocouplers. Yeah I'd better do it now or I'll never do it.  

You are absolutely correct (great observation) re: width. Here's where I assumed it was the same as the RPi Pico and didn't measure or check Pete's gerbers.

I toyed with the idea of a pull-down on the MIC2981 but I have thoroughly tested these things with all kinds of loads and haven't seen the need. I will look at it  
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7828
Posted: 11:51am 04 Jul 2025
Copy link to clipboard 
Print this post

I wonder if that's my fault? I think I might have done a 0.9" footprint for SL6....
Mick

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

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1441
Posted: 11:58am 04 Jul 2025
Copy link to clipboard 
Print this post

Well for this black duck done enough today and got food for thought and I'm sure more posts will follow.

As far as what pins I use for each axis can be decided tomorrow as I do think that count pin is needed to count the steps.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7828
Posted: 12:04pm 04 Jul 2025
Copy link to clipboard 
Print this post

Very red-faced. :(
Here's the fixed version!
Pico2-64.zip
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.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025