|
Forum Index : Microcontroller and PC projects : Stepper Project
| Author | Message | ||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
OK with the list system I2C I found if I took the I2C wires from the zero off the pico 2 I2C pins got the top one now the lower one is when I connected the zero I2C and the zero is unpowered. > list system i2c HEX 0 1 2 3 4 5 6 7 8 9 A B C D E F 00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > ? time$ 01:42:47 > RTC settime 2026, 05, 16, 12, 30, 0 > ? time$ 12:30:08 > list system i2c HEX 0 1 2 3 4 5 6 7 8 9 A B C D E F 00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- -- -- -- -- -- - |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
Well I thought as that regulator was getting hot it was toast so soldered up a new Mixtel board with a new zero. Yet when I connect the zero's I2C pins to the pico 2 I2C pins the RTC I2C lines are lost, take off the zero I2C pins and the RTC is seen. I even got around to putting 4K7 pullups on with has made no difference. |
||||
TassyJim![]() Guru Joined: 07/08/2011 Location: AustraliaPosts: 6529 |
I think you have to have the zero powered and the I2C set to slave when they are tied together. Jim VK7JH MMedit |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
Jim I did do OPTION SYSTEM I2C GP14, GP15 on the zero and doing an option list shows the I2C there. Now just had some fun found that led wasn't lighting and it turned out this lithuim battery after I gave it a good charge with this Ching board actually killed the battery so went and found my old AAA 4 battery pack and used that for power. Powered it up with zero turned on by the 5V rail and it is still the same when the zero is connected the system I2C is clear, take the zero I2C wires out and the RTC is seen again. Just looked at the manual and for the Option System I2C(2) there isn't an option to set it to slave. Ok just found the I2C Apendix B in the manual and there is I2C Slave Open addrs, send_int, rvc_int. So it does look like this needs to be in a program and not the command line so I need to make 2 subs and run the zero with the I2C wires off the pico 2 Edited 2026-05-16 16:27 by Bryan1 |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8842 |
The on-board regulator on the Zero can provide a max of about 100mA (in addition to powering the RP2040). I usually keep it under that as the heatsink (the USB connector) isn't brilliant. If you keep within its limit things run cool, in my experience. Do pay particular attention to the point I made about the USB supply NOT being isolated by a diode from the 5V pin though! You can damage some PCs by having this pin on a 5V supply while the USB lead is connected. I would suggest: Power the Pico at 5V. Do not connect the 5V pin on the Zero. Link the GND and 3V3 pins on the two modules together, with the 3V3 via a jumper. Connect the I2C pullup resistors to the 3V3 supply from the Pico. Ideally the 3V3 from the Pico should have a diode to the 3V3 pin on the Zero rather than a jumper but that's introducing too much volt drop to be safe. The jumper allows you to program the Zero without powering the Pico and anything else attached to its 3V3. It would really be better to use a 5V to 3V3 switcher and power both modules from that at 3V3. Disable the 3V3 reg on the Pico and don't connect the 5V, VBUS or VSYS pins. Something like the SO6 module is very cheap and can provide a solid 500mA, but any small buck regulator will do. This has several advantages. It reduces noise pick-up on the supply rail, reduces 3V3 rail impedance to reduce switching spikes and makes the power supply more flexible - you could power it with anything between 5V and 12V, smooth or not. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
TassyJim![]() Guru Joined: 07/08/2011 Location: AustraliaPosts: 6529 |
Just guessing again: Don't use SYSTEM I2C on the module that is a slave. Setting SYSTEM I2C assumes that it will be a Master. Just use SETPIN sda, scl, I2C/I2C2 Jim VK7JH MMedit |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
Well a big rethink about using the zero on I2C it was all around me using that lithium pack along with this ching charger, now that I've killed the battery the idea of battery management is off the table. My Sprint layout should be ready to FAB but still go to put in the console output and a passive board designed to use Lyle's circuit with the opto's made and provide a 12 volt input to the 5V reg, now I do have some some 3V3 reg's too so one of them could be used. Then tomorrow I can setup the BC337's for the stepper outputs along with the 22K and 1K resistors then put in the stepper code to my program so this project cam move forward. So what I'm thinking is getting the stepper INIT code in early then the 3 display box's I setup in the code can actually show the position of the machine instead of the 0.000 String I put in. Then when the display box on each axis can be used as the _pos for the stepper code and the DIR can be set and made a string by using the toggle switch so DIR will be 1 or 0 and move the distance of the _pos string depending on the axis. I do think another displaybox should be made so the feedrate can be assigned to the F_pos for the stepper string. Once this is all done I should be able to move each axis to establish the actual position of the machine. There is still a longway to go and getting the steppers to move in my code will get it over V0.01 Now once the X axis and Y axis stepper code is sorted out where the X axis is just going back and forwards and be a constant distance as we only need to clear the magnetic table and the Y axis is just going to increment depending on the grinding wheel width. I do think that will be the version update as the X axis and Y axis is sorted then comes the Z axis where a grinding wheel is doing 2,500 rpm depending on the diameter and depth of cut where if any problems are in use the E_Stop will cut the Y axis and X cam move away from the magnetic table leave so in reality the Z axis should raise to clear the job so the E_Sop is only to stop the job. Now with surface grinding depending on the job only a few pass's are needed where the depth of cut can be measured in steps rather than distance then we need to turn the job over. So the E_Stop function can be used for changing the work setting then a new run page on the lcd can move the stepper step by step to get the grinding started. Now I am thinking about the limit switch's as they won't be needed as the Y axis is just going to clear each side of the magnetic table and for a X axis the magnetic table is 1/2 the X axis travel. The Z axis travel will only really move when a smaller grinding is put on but again in reality if we use the same diameter grinding wheel the Z axis is only going to move a small difference so referencing the limits in the code would do which would bring 3 in/outs free which could be used for enable pins. So Lyle how does sound to you mate and can I wake up tomorrow morning seeing that you updated my code to work with the stepper code so I have to wire up the X and Y axis to the DM556's to test the code. Regards Bryan |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8842 |
Unless your application needs speed you may well be able to drop the CPU speeds, which also drops the current consumption if that's important. 48MHz is still blindingly fast - they will still spend most of the time waiting for something to happen. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| mozzie Guru Joined: 15/06/2020 Location: AustraliaPosts: 330 |
G'day Bryan, Sorry to say a 50th last night + a few too many bevvies + getting home at 05:30 means any programming today would be null and void Happy to have a look later today (hmmm maybe) or tomorrow and see what I can come up with Regards, Lyle. |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3222 |
Happy Birthday Lyle! I guess this isn't needed now but here is a workaround for the I2C Slave freeze issue. Hopefully a future firmware version won't need it. In the meantime it would be helpful if the problem could be mentioned in the manual. ' I2C slave program with antifreeze Dim integer SDApin = mm.info(pinno GP0), SCLpin = mm.info(pinno GP1) 'choose your pins SetPin SDApin, SCLpin, I2C I2C SLAVE OPEN &H52, TXint, RXint 'Transmit and receive ISRs Dim Integer RXbytes = 8 'set the number of bytes to receive Do : Pause 5 : Loop Until Inkey$<>"" 'main loop Sub RXint count, a$ I2C SLAVE READ RXbytes, a$, count Print Left$(a$, count), count End Sub Sub TXint Local a$ = DateTime$(now) 'data to send I2C SLAVE WRITE Len(a$), a$ Pause len(a$) / 33 'allow time for Write to complete If MM.I2C Then 'close and re-open I2C if requested bytes <> len(a$) I2C close SetPin SDApin, SCLpin, I2C I2C SLAVE OPEN &H52, TXint, RXint EndIf Print "Slave sent = ";a$ End Sub Print "End" End I2C Master testing console program. The slave program above will be sending 19 bytes when requested. These are the output when 19, 30 and 10 bytes are requested, 6 times each to show success isn't a fluke. > SetPin GP12, GP13, I2C : I2C OPEN 100, 1000 > A$="" : For n=0 To 5 : I2C read &H52, 0, 19 ,A$ : Print A$ : pause 999 : Next 17-05-2026 16:48:07 'requesting the correct number of bytes, 19 17-05-2026 16:48:08 17-05-2026 16:48:09 17-05-2026 16:48:10 17-05-2026 16:48:11 17-05-2026 16:48:12 > 'requesting the wrong number, 30 > A$="" : For n=0 To 5 : I2C read &H52, 0, 30 ,A$ : Print A$ : pause 999 : Next 17-05-2026 16:48:41ÿÿÿÿÿÿÿÿÿÿÿ 17-05-2026 16:48:42ÿÿÿÿÿÿÿÿÿÿÿ 17-05-2026 16:48:43ÿÿÿÿÿÿÿÿÿÿÿ 17-05-2026 16:48:44ÿÿÿÿÿÿÿÿÿÿÿ 17-05-2026 16:48:45ÿÿÿÿÿÿÿÿÿÿÿ 17-05-2026 16:48:46ÿÿÿÿÿÿÿÿÿÿÿ > 'requesting the wrong number, 10 > A$="" : For n=0 To 5 : I2C read &H52, 0, 10 ,A$ : Print A$ : pause 999 : Next 17-05-2026 17-05-2026 17-05-2026 17-05-2026 17-05-2026 17-05-2026 > Edit. the "ÿ" bytes are 255 As the freeze only occurs after the data has been successfully sent it would appear matching the requested number of bytes with the number of bytes to be sent isn't really required. So perhaps this is the result of a bug rather than improper use in a program. Edited 2026-05-17 21:01 by phil99 Footnote added 2026-05-18 08:40 by phil99 Bugs now fixed in v6.03.00RC9, including I2C READ accepting a 1 byte string. Footnote added 2026-05-18 09:12 by phil99 Using RC9 to check for errors. When the Master requests double the number of bytes available from the slave the data is repeated, so compare the two halves. > A$="" : For n=0 To 5 : I2C read &H52, 0, 19*2 ,A$ : ? left$(A$,len(A$)/2), right$(A$,len(A$)/2) : pause 999 : Next 18-05-2026 09:05:38 18-05-2026 09:05:38 18-05-2026 09:05:39 18-05-2026 09:05:39 18-05-2026 09:05:40 18-05-2026 09:05:40 18-05-2026 09:05:41 18-05-2026 09:05:41 18-05-2026 09:05:42 18-05-2026 09:05:42 18-05-2026 09:05:43 18-05-2026 09:05:43 > |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
Well that 4" lcd turned up this morning soldered on the 4 pin connector for the SDCard and replaced the ILI9488 with the new ST7796, now in the manual it stated the lcd driver is a ST7796S so used that for the option lcdpanel.Now I took off that 10K diode hack for the ILI9488 and left MISO unconnected, did a clear flash and installed RC9 and after putting the options in everything just worked Now also I did read this lcd can work on 3V3 by jumpering J1 and bridging D1 so haven't done that yet. Now with just the USB cable connected there is just over 4 volts on the Vcc bus and with the suggestions of going 3V3 it does make sense as for testing the usb cable won't be connected and the circuit can run of those 4 off AAA batteries in series and I want to replace the 5V regulator with a 3V3 one so would I need to put a diode on the 3V3 regulator to stop the higher USB voltage damaging the 3V3 regulator. Now I just did a reboot and saw both the LCD screen and MCCC off on it's own tangent > > option list PicoMite MMBasic RP2350A V6.03.00RC9 OPTION SYSTEM SPI GP18,GP19,GP16 OPTION SYSTEM I2C GP10,GP11 OPTION FLASH SIZE 4194304 OPTION COLOURCODE ON OPTION CPUSPEED (KHz) 200000 OPTION LCDPANEL CONSOLE OPTION DISPLAY 26, 60 OPTION LCDPANEL ST7796S, LANDSCAPE,GP15,GP14,GP13,GP20 OPTION TOUCH GP12,GP17 OPTION SDCARD GP21 > gui calibrate Warning: Inaccurate calibration Deviation X = 1, Y = 34 (pixels) > option list PicoMite MMBasic RP2350A V6.03.00RC9 OPTION SYSTEM SPI GP18,GP19,GP16 OPTION SYSTEM I2C GP10,GP11 OPTION FLASH SIZE 4194304 OPTION COLOURCODE ON OPTION CPUSPEED (KHz) 200000 OPTION LCDPANEL CONSOLE OPTION DISPLAY 26, 60 OPTION LCDPANEL ST7796S, LANDSCAPE,GP15,GP14,GP13,GP20 OPTION TOUCH GP12,GP17 GUI CALIBRATE 0, 3939, 3909, -1296, -741 OPTION SDCARD GP21 > Disconnected Connected to COM12 at 115200 B:/ > <DIR> dtxhelp > :48 18-02-2012 589 dates.txt > :10 05-07-2013 108160 DTXHELP.TXT > :11 19-08-2018 2039 EDITOR.TXT > :11 19-08-2018 799 FUN1WIRE.BAS > :15 10-01-2026 16315 Kanmantoo Distilling.docx > :11 19-08-2018 4798 ONEWIRE.BAS > :13 18-08-2018 23970870 ruff.bmp > :06 01-01-2024 96822 SD Card Test.BMP > :00 01-01-2000 640 TEMP.BAS > directory, 9 files > a: > files > / > <DIR> . > <DIR> .. > :00 01-01-2024 4 bootcount > directories, 1 file, 1822720 bytes free > gui test lcdpanel > 00.7936 Circles per Second > ? time$ > :02:06 Doing the reboot fixed the problem so not sure why on a reconnect it went straight to B drive then to A drive, Also it tried to do a gui test lcdpanel. O'well still got to wire up those push buttons to emulate the E_Stop and limits and load the 2040 RC9 on the zero so I try the fix for the I2C. Now it does look like that 2032 button battery is gone as the RTC won't keep time when powered down. Regards Bryan Regards Bryan |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 5884 |
OPTION RTC AUTO ? Volhout PicomiteVGA PETSCII ROBOTS |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
> rtc settime 2026, 05, 18, 14, 52,0 > ? time$ 14:52:06 > option rtc auto Error : Invalid Option Now looking in the manual forgot the enable Got a brandnew 2032 battery in too Now I'm playing with my code and found page 5 wasn't responding to a button press so I put in down to a sloppy calibration and did a option reset and found with more careful press's on the calibration did fix the problem. Now with this 4" screen about 6mm on the right of the screen is blanked out so I need the command the command to widen the resoultion. Edited 2026-05-18 15:30 by Bryan1 |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3222 |
RTC GETTIME : ? DateTime$(now) Will tell you if the RTC is running. If it is then as Volhout wrote:- OPTION RTC AUTO enable . Edited 2026-05-18 15:28 by phil99 |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
Thanks Phil > RTC GETTIME : ? DateTime$(now) 18-05-2026 15:00:03 |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
Well having a bit of fun setting up the stepper code and finally got over my syntax errors on error skip stepper close STEPPER init 0.05, 150, GP22 stepper axis X, GP2, GP3, GP1,, 600,, stepper axis Y, GP4, GP5, GP1,, 600,, stepper axis Z, gp6, gp7, gp1,, 600,, stepper hwlimits gp26, gp27, gp28, gp26, gp27, gp28 stepper spindle GP0 Now the next error [20] Stepper axis Y, GP4, GP5, GP1,, 600,, Error : Pin 2/GP1 is in use doing a list pins [CODE> list pins GP0 1 OFF GP1 2 DOUT: Reserved for function GP2 4 DOUT: Reserved for function GP3 5 DOUT: Reserved for function GP4 6 DOUT GP5 7 DOUT GP6 9 OFF GP7 10 OFF GP8 11 OFF GP9 12 OFF] Now no where in my code have I set any pins |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
So I set GP1 to GP7 as DOUT setpin gp1, dout setpin gp2, dout setpin gp3, dout setpin gp4, dout setpin gp5, dout setpin gp6, dout setpin gp7, dout Yet still get Stepper initialized - 100KHz timer active Warning: Soft limits not configured. Use STEPPER LIMITS to set working area. [28] Stepper axis Y, GP4, GP5, GP1,, 600,, Error : Pin 2/GP1 is in use So why won't the pico 2 let me use these pins, thinking it could be as I set GP1 to enable X and it saying can't use a single enable pin for X,Y and Z Edited 2026-05-18 16:27 by Bryan1 |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3222 |
Option List should indicate if anything there is using them. If nothing is then at the command prompt enter:- setpin gp1,off : setpin gp2,off : setpin gp3,off Then try again. |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2002 |
> setpin gp1, off : setpin gp2 off : setpin gp3 off Error : Pin 2/GP1 is in use Done on the commandline too > option list PicoMite MMBasic RP2350A V6.03.00RC9 OPTION SYSTEM SPI GP18,GP19,GP16 OPTION SYSTEM I2C GP10,GP11 OPTION FLASH SIZE 4194304 OPTION COLOURCODE ON OPTION CPUSPEED (KHz) 200000 OPTION LCDPANEL CONSOLE OPTION DISPLAY 26, 60 OPTION LCDPANEL ST7796S, LANDSCAPE,GP15,GP14,GP13,GP20 OPTION GUI CONTROLS 75 OPTION TOUCH GP12,GP17 GUI CALIBRATE 0, 3951, 3900, -1289, -854 OPTION SDCARD GP21 OPTION RTC AUTO ENABLE Edited 2026-05-18 16:30 by Bryan1 |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11352 |
You can't use the same pin twice. Set the enable pin on just one axis and WIRE it to them all |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |