I've posted about this before in user demos. I have some code to control 2 unipolar motors that works using case select to pick the value to send to port to control motor.
I change it to read table for less code and it doesn't work. motors go in 1 direction instead of the program.
The program uses a i2c to expander but the values sent are the same from case select as readtable..but not because it doesn'twork with table version.
2 lists. first works, second using table doesn't.
I could stick with working case version but want to know why table version doesn't work as less code.
Nice code to use cheap stepper gear motors.
It's all in sub motors
I don't do much with the '328. Because you are the expert, i have a question. At what speed does the system clock run? Is it 16 mhz/8 = 2 mhz? The pdf says the "system clock prescaler is set at divide by 8 when shipped.
I am just trying to determine if you are sending stuff to your motors too fast.
Have you measured how long it is in each motor state?
I am using a 16F886 and leds on portB to simulate the output of the "motors" sub and it works fine with "reaadtable" on my protoboard.
BR
mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mike, I put the line portb.0=!portb.0 ;scope pin in the interrupt to scope the frequency as I not got interrupt calculations sorted. I think it's twice the scope result as I just flip the port bit.
I can't help with default avr stuff sorry. It's what gcb mega328p,16 means. Instruction every clock.
The motor spec is 100Hz. I use intspeed interrupt timer variable to change speed. It works like a dc motor not a stepper but without the interrupt could be normal stepper.
I should check the table values in terminal. I can't see my error.
I tried 0b10010000,0b11000000,0b01100000,0b00110000
and it looked wrong in the ide.
b'10010000',b'11000000',b'01100000',b'00110000'
looked odd with first b black and rest of line red
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mike,star you are. I checked the motor pulse rate and it was 175Hz. Lowering it and the table version worked.
I saved 54 bytes prog space but used 2 more bytes ram.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the Atmel 42735 Datasheet it says" The device is shipped with the CKDIV8 Fuse programmed". But this can be changed by programming the "CLKPS" bits. I don't see the CLKPS in the program except to define the address of the register. So the clock would be every 0.0000005 s? 2mhz
What did you measure with your scope on the portB.0?
Is the I2C on the '328, hardware or software?
BR
mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using a nano 328p but not a clue as to fuses or strong pullups.
The timer over flow interrupt is from gcb demos. as is the expander code.
It's freqency is double what scope says. I've error here.
I'm using the nano sda and scl pins but not hardware i2c. I didn't notice, age. I'll try hi2c.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I looked through demos for checking hi2c or i2c and didn't find any. Is it checking for #define HI2C_DATA ? Not a 5 minute job as I spent 6 minutes and am no wiser :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's the project. no batteries yet. runs so slow n smooth. obstacle avoidance can take it's time. I have plans for this..ie it won't fall off the table :) https://youtu.be/Td7yWYImjr4
edit note 4 wires to dragging nano +-clk,sda. expander is neat and uln2803
Last edit: stan cartwright 2018-03-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've posted about this before in user demos. I have some code to control 2 unipolar motors that works using case select to pick the value to send to port to control motor.
I change it to read table for less code and it doesn't work. motors go in 1 direction instead of the program.
The program uses a i2c to expander but the values sent are the same from case select as readtable..but not because it doesn'twork with table version.
2 lists. first works, second using table doesn't.
I could stick with working case version but want to know why table version doesn't work as less code.
Nice code to use cheap stepper gear motors.
It's all in sub motors
and the table version that doesn't work
@stan,
I don't do much with the '328. Because you are the expert, i have a question. At what speed does the system clock run? Is it 16 mhz/8 = 2 mhz? The pdf says the "system clock prescaler is set at divide by 8 when shipped.
I am just trying to determine if you are sending stuff to your motors too fast.
Have you measured how long it is in each motor state?
I am using a 16F886 and leds on portB to simulate the output of the "motors" sub and it works fine with "reaadtable" on my protoboard.
BR
mike
Mike, I put the line portb.0=!portb.0 ;scope pin in the interrupt to scope the frequency as I not got interrupt calculations sorted. I think it's twice the scope result as I just flip the port bit.
I can't help with default avr stuff sorry. It's what gcb mega328p,16 means. Instruction every clock.
The motor spec is 100Hz. I use intspeed interrupt timer variable to change speed. It works like a dc motor not a stepper but without the interrupt could be normal stepper.
I should check the table values in terminal. I can't see my error.
I tried 0b10010000,0b11000000,0b01100000,0b00110000
and it looked wrong in the ide.
b'10010000',b'11000000',b'01100000',b'00110000'
looked odd with first b black and rest of line red
Mike,star you are. I checked the motor pulse rate and it was 175Hz. Lowering it and the table version worked.
I saved 54 bytes prog space but used 2 more bytes ram.
Thanks.
Stan,
In the Atmel 42735 Datasheet it says" The device is shipped with the CKDIV8 Fuse programmed". But this can be changed by programming the "CLKPS" bits. I don't see the CLKPS in the program except to define the address of the register. So the clock would be every 0.0000005 s? 2mhz
What did you measure with your scope on the portB.0?
Is the I2C on the '328, hardware or software?
BR
mike
I'm using a nano 328p but not a clue as to fuses or strong pullups.
The timer over flow interrupt is from gcb demos. as is the expander code.
It's freqency is double what scope says. I've error here.
I'm using the nano sda and scl pins but not hardware i2c. I didn't notice, age. I'll try hi2c.
Thanks.
The MCP23017 include is i2c so just change to hi2c and the program i2c to hi2c?
You were correct about the interrupt. It should have been
Table still not working though. More testing needed.
If would be best if someone simply updated https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/MCP23017.h to support software and hardware I2C then the library would automatically detect the use of software or the hardware i2c.
I looked through demos for checking hi2c or i2c and didn't find any. Is it checking for #define HI2C_DATA ? Not a 5 minute job as I spent 6 minutes and am no wiser :)
You are updating a library. Look in the include folder of your installation. Examples would include most of the DS type clock libraries. DS1307.
Here's the project. no batteries yet. runs so slow n smooth. obstacle avoidance can take it's time. I have plans for this..ie it won't fall off the table :) https://youtu.be/Td7yWYImjr4
edit note 4 wires to dragging nano +-clk,sda. expander is neat and uln2803
Last edit: stan cartwright 2018-03-13