|
Post by alexfish on Jan 14, 2024 20:46:14 GMT 1
Taking a breather Conversation TODAY Q:: what are the Heaviest Objects in the Universe A: See Picky Heavy Attachments:
|
|
|
Post by alexfish on Jan 14, 2024 22:03:21 GMT 1
DEF Last in The Pico Bits Getting The Port Two Way Conversation First Test Read Char By Char Use the Libserial Hug version Code & Details to be Posted on New Thread Soon & Yes, That is the USB port BR Alex PiCoky Second Pick Full Strings Stringys Attachments:
|
|
|
Post by alexfish on Jan 15, 2024 21:27:15 GMT 1
Ans So to Masking the Gpio
Here Masking the port for Single Motor (using 4 pin stepper controller) Can be adapted For Rasperry Pi & Also the Pico
Example:: demo Purposes only , Bit masking
REM all mask 1111111111100 CONST SET_ALL_MASK = 0x1ffc REM motor mask 0001111111100 CONST MOTOR_MASK = 0x3fc
CONST FIRST_MOTOR = 2 CONST MOTOR_OFFSET = 4 DECLARE MOTOR_MASK$ = "0001111111100" DECLARE spin_right[4] = {8 << FIRST_MOTOR,4 << FIRST_MOTOR,2 << FIRST_MOTOR, 1 << FIRST_MOTOR} TYPE const int DECLARE spin_left[4] = {1 << FIRST_MOTOR, 2 << FIRST_MOTOR,4 << FIRST_MOTOR,8 << FIRST_MOTOR} TYPE const int
REM ================================================ FUNCTION DecToBinary$(unsigned int n) TYPE STRING LOCAL binaryNum[1000] LOCAL i LOCAL bin$
WHILE (n > 0) DO binaryNum[i] = n % 2 bin$ = bin$ & STR$(binaryNum[i]) n = n / 2 INCR i WEND '' RETURN bin$ END FUNCTION REM ================================================================ SUB single_motor_turn(char motor,const int direction[],int sleep_time) LOCAL shift = MOTOR_OFFSET * motor LOCAL val , mask LOCAL bin$
FOR val = 0 TO 3 mask = direction[val] << shift PRINT mask bin$ = DecToBinary$(mask) sp$=SPC$(8-LEN(bin$)) sp$ = REPLACE$(sp$," ","0") PRINT sp$ & REVERSE$(bin$) NEXT PRINT END SUB REM =MAIN ========================================================== LOCAL current_motor = 0 TYPE char PRINT " Spin Right" single_motor_turn(current_motor, spin_right, 2) PRINT " Spin Left" single_motor_turn(current_motor, spin_left, 2) REM ================================================================
results from the Term
Spin Right 32 00100000 16 00010000 8 00001000 4 00000100
Spin Left 4 00000100 8 00001000 16 00010000 32 00100000
Have Fun BR Alex
|
|
|
Post by alexfish on Jan 16, 2024 18:37:52 GMT 1
Here:: can test interpolate : On two wire : on wire = Dir on first then interpolate 3 axis
all bits the same but added
DECLARE Step_XYZ[4] = {1 << FIRST_MOTOR, 3 << FIRST_MOTOR,5 << FIRST_MOTOR,7 << FIRST_MOTOR} TYPE const int
Further work = DIY to suit
all the bits
REM all mask 1111111111100 CONST SET_ALL_MASK = 0x1ffc REM motor mask 0001111111100 CONST MOTOR_MASK = 0x3fc
CONST FIRST_MOTOR = 2 CONST MOTOR_OFFSET = 4 DECLARE MOTOR_MASK$ = "0001111111100" DECLARE spin_right[4] = {8 << FIRST_MOTOR,4 << FIRST_MOTOR,2 << FIRST_MOTOR, 1 << FIRST_MOTOR} TYPE const int DECLARE spin_left[4] = {1 << FIRST_MOTOR, 2 << FIRST_MOTOR,4 << FIRST_MOTOR,8 << FIRST_MOTOR} TYPE const int DECLARE Step_XYZ[4] = {1 << FIRST_MOTOR, 3 << FIRST_MOTOR,5 << FIRST_MOTOR,7 << FIRST_MOTOR} TYPE const int REM ================================================ FUNCTION DecToBinary$(unsigned int n) TYPE STRING LOCAL binaryNum[1000] LOCAL i LOCAL bin$
WHILE (n > 0) DO binaryNum[i] = n % 2 bin$ = bin$ & STR$(binaryNum[i]) n = n / 2 INCR i WEND '' RETURN bin$ END FUNCTION REM ================================================================ SUB single_motor_turn(char motor,const int direction[],int sleep_time) LOCAL shift = MOTOR_OFFSET * motor LOCAL val , mask LOCAL bin$
FOR val = 0 TO 3 mask = direction[val] << shift PRINT mask bin$ = DecToBinary$(mask) sp$=SPC$(8-LEN(bin$)) sp$ = REPLACE$(sp$," ","0") PRINT sp$ & REVERSE$(bin$) NEXT PRINT END SUB REM =MAIN ========================================================== LOCAL current_motor = 0 TYPE char PRINT " Spin Right" single_motor_turn(current_motor, spin_right, 2) PRINT " Spin Left" single_motor_turn(current_motor, spin_left, 2) PRINT "Step pulse InterPolate" single_motor_turn(current_motor, Step_XYZ, 2)
REM ================================================================ on interpolate Note which part of the array gives the result Reason: Will need more variants of the initial 'Step_XYZ' one set XYZ and say another YXZ an so on Have Fun + BR Alex
|
|
|
Post by alexfish on Jan 16, 2024 20:06:48 GMT 1
And So To Interpolate XYZ axis using steppers drivers 2/3 wire control to 4 wire
REM interpolate stepper steps XYZ REM all mask 1111111111100 CONST SET_ALL_MASK = 0x1ffc REM motor mask 0001111111100 CONST MOTOR_MASK = 0x3fc
CONST STEPER_MOTORS = 2 CONST MOTOR_OFFSET = 4
DECLARE Step_X = 1 << STEPER_MOTORS TYPE const int DECLARE Step_Y = 2 << STEPER_MOTORS TYPE const int DECLARE Step_Z = 4 << STEPER_MOTORS TYPE const int DECLARE Step_XY = 3 << STEPER_MOTORS TYPE const int DECLARE Step_XYZ = 7 << STEPER_MOTORS TYPE const int DECLARE Step_XZ = 5 << STEPER_MOTORS TYPE const int DECLARE Step_YZ = 6 << STEPER_MOTORS TYPE const int REM ================================================ FUNCTION DecToBinary$(unsigned int n) TYPE STRING LOCAL binaryNum[1000] LOCAL i LOCAL bin$
WHILE (n > 0) DO binaryNum[i] = n % 2 bin$ = bin$ & STR$(binaryNum[i]) n = n / 2 INCR i WEND '' RETURN bin$ END FUNCTION REM ================================================================
SUB STEPPER(char motor,const int step,int sleep_time) LOCAL shift = MOTOR_OFFSET * motor LOCAL mask LOCAL bin$
mask = step << shift PRINT mask bin$ = DecToBinary$(mask) sp$=SPC$(8-LEN(bin$)) sp$ = REPLACE$(sp$," ","0") PRINT sp$ & REVERSE$(bin$) END SUB REM =MAIN ========================================================== LOCAL current_motor = 0 TYPE char
STEPPER(current_motor, Step_X, 2) STEPPER(current_motor, Step_Y, 2) STEPPER(current_motor, Step_Z, 2) STEPPER(current_motor, Step_XY, 2) STEPPER(current_motor, Step_XYZ, 2) STEPPER(current_motor, Step_XZ, 2) STEPPER(current_motor, Step_YZ, 2) Have Fun + BR Alex
Tec Tips :: connections
Stepper wire :: use shielded usb :: use shielded
next up :: hug gui for testing + combine Masking the DIR/+ - with Stepper/Step :: required two wire set up :: IE Circle interpolation
|
|
|
Post by alexfish on Jan 18, 2024 4:20:24 GMT 1
Hi All GPIO & PIO(PICO) Progress update Stepper functions :Interpolate: both libs indicate that the first 8 bits(byte) are same for pico and Wiring PI the pico and the Wiring PI code base will be the same the base code will more or less match BaCon , further to this :: the original Pico thread: now to be named GPIO and = pico code and Wiring PI making this thread a bit redundant :: for demo purposes some code in pico-basic to compare then picky's : hence the above demo BASIC then picky's LOCAL onoff = 0 TYPE bool LOCAL LED_PIN = 25 TYPE const uint LOCAL strg[STRINGBUF] TYPE STRING LOCAL chr TYPE char LOCAL lp = 0 TYPE int
MEMORY(strg, 0, sizeof(strg))
gpio_init(LED_PIN) gpio_set_dir(LED_PIN, GPIO_OUT)
WHILE 1 DO
chr = INPUT(FALSE) WHILE chr != ENDSTDIN DO
strg[lp++] = chr IF (chr == CR || lp == (sizeof(strg) - 1)) THEN
REM terminate string strg[lp] = 0 IF (LEN(strg) ) THEN PRINT "Received - \n %s\n", strg IF (strg[0] == 'P') THEN PRINT "%s\n",prog END IF END IF
MEMORY(strg, 0, sizeof(strg)) REM reset string buffer pointer lp = 0 BREAK END IF
LET chr = INPUT(FALSE) WEND
gpio_put(LED_PIN, onoff) onoff = !onoff SLEEP 100 WEND Back Soon with new thread + Note How the serial port finds the device if the /dev/ttyACM0 number changes to say ttyACM1Q: if using the pico as the driver* ,how does view the results , A: in this instance, the pico does not need a screen code will be sent back & then drawn in the hug gui canvas IE test feedback using the serial port : in the main does not need to see a serial(gui) the canvas drawing functions will be built into the device IE CIRCLE LINE ARC etc etc this is a sample of an instruction Received - G0 X 0.479426 Multiple lines G1 X 100.017452 G1 X 100.034899 G1 X 100.052336 G1 X 100.069756 G1 X 100.087156 G1 X 100.104528 G1 X 100.121869 G1 X 100.139173 G1 X 100.156434 G1 X 100.173648 G1 X 100.190809 G1 X 100.207912 G1 X 100.224951 G1 X 100.241922 G1 X 100.258819 G1 X 100.275637 G1 X 100.292372 G1 X 100.309017 G1 X 100.325568 G1 X 100.342020 G1 X 100.358368 G1 X 100.374607 G1 X 100.390731 G1 X 100.406737 G1 X 100.422618 G1 X 100.438371 G1 X 100.453990 G1 X 100.469472 G1 X 100.484810 G1 X 100.500000 G1 X 100.515038 G1 X 100.529919 G1 X 100.544639 G1 X 100.559193 G1 X 100.573576 G1 X 100.587785 G1 X 100.601815 G1 X 100.615661 G1 X 100.629320 G1 X 100.642788 G1 X 100.656059 G1 X 100.669131 G1 X 100.681998 G1 X 100.694658 G1 X 100.707107 G1 X 100.719340 G1 X 100.731354 G1 X 100.743145 G1 X 100.754710 G1 X 100.766044 Hence same as using hug gcode canvas , the Received will not be seen , happy with the results : PRESS RUN read the last few pages of this thread BR Alex Attachments:
|
|
|
Post by alexfish on Jan 21, 2024 4:00:41 GMT 1
Hi All Updater Hug353 to be update New API dialog widget FILEOPEN & FILSAVE the updates will encompass most of what is in this thread. widget wise = best suited for small screens these are file dialog WIDGETS Bug fixes in progress . FIXED :due: 28/JAN/2024 Demo of how the widgets work SEE Picky BR Alex Attachments:
|
|