As most of you know I abandoned the SDCC C compiler for PIC microcontrollers in favour of the rather inexpensive Oshonsoft IDE Basic compiler created and supported by Vladimir Soso in Serbia. I've not regretted the choice.
This morning Vladimir sent along a notification of an extension to his BASIC compiler that handles the following chips...
These are an interesting family of chips. At US$0.40-US$0.60 they are very inexpensive. They don't have a UART and they have, typically, only a few hundred words of memory, maybe 4-6 I/O pins and 0-3 A/D channels, depending on which chip you choose. While their capacity is small they are quite a nice choice if you need to run, say, a pseudostepper motor or condition a signal from an unsophisticated sensor. They can also talk to bigger PIC chips via Vladimir's software serial links that use ordinary I/O ports and can operate reliably up to 9600 bps.
I'm probably going to go over the 18F PIC microcontrollers when I do the shift to USB from RS232 serial comms. Vladimir has also recently offered an add-on pack to handle USB communications for PIC18F's.
It appears that Vladimir at Oshonsoft would like more customers. He's built stepper motor support right into his BASIC compiler.
● Interfacing Stepper Motors
Prior to using stepper motor related statements, its connection and desired drive mode should be set up using DEFINE directives. There are eight available parameters to define the connection of A, B, C and D coils:
STEP_A_REG - defines the port where A coil is connected to
STEP_A_BIT - defines the pin where A coil is connected to
STEP_B_REG - defines the port where B coil is connected to
STEP_B_BIT - defines the pin where B coil is connected to
STEP_C_REG - defines the port where C coil is connected to
STEP_C_BIT - defines the pin where C coil is connected to
STEP_D_REG - defines the port where D coil is connected to
STEP_D_BIT - defines the pin where A coil is connected to
Coils A and C are actually parts of one single coil with common connection. The same is valid for B and D coil connections. There is also STEP_MODE parameter used to define the drive mode. If it is set to 1 (default) the motor will be driven in full-step mode. The value 2 should be used for half-step mode. The first basic statement that should be used is STEPHOLD. It will configure used pins as outputs and also energize A and B coils to fix the rotor in its initial position. For moving rotor in clockwise and counterclockwise directions there are STEPCW and STEPCCW statements available. Their first argument is the number of rotor steps that will be performed and it can be Byte data type constant or variable. The second argument defines the delay between consecutive steps expressed in microseconds by a Byte or Word data type variable or constant. If using STEPCW statement results in rotor movement in counterclockwise direction then connection settings for B and D coils should be exchanged. Here are two examples (the second example uses delays suitable for simulation in the simulator):
As most of you know I abandoned the SDCC C compiler for PIC microcontrollers in favour of the rather inexpensive Oshonsoft IDE Basic compiler created and supported by Vladimir Soso in Serbia. I've not regretted the choice.
This morning Vladimir sent along a notification of an extension to his BASIC compiler that handles the following chips...
10F200, 10F202, 10F204, 10F206, 10F220, 10F222, 12F508, 12F509, 12F510, 16F505, 16F506
These are an interesting family of chips. At US$0.40-US$0.60 they are very inexpensive. They don't have a UART and they have, typically, only a few hundred words of memory, maybe 4-6 I/O pins and 0-3 A/D channels, depending on which chip you choose. While their capacity is small they are quite a nice choice if you need to run, say, a pseudostepper motor or condition a signal from an unsophisticated sensor. They can also talk to bigger PIC chips via Vladimir's software serial links that use ordinary I/O ports and can operate reliably up to 9600 bps.
http://www.oshonsoft.com/pic10f.html
I'm probably going to go over the 18F PIC microcontrollers when I do the shift to USB from RS232 serial comms. Vladimir has also recently offered an add-on pack to handle USB communications for PIC18F's.
http://www.oshonsoft.com/pic18usb.html
You can get a better look at just how easy it is to impliment USB comms with the 18F4550 here...
http://www.oshonsoft.com/pic18usbhard.png
I'm looking hard at this chip and a few more like it. It costs about US$5.
It appears that Vladimir at Oshonsoft would like more customers. He's built stepper motor support right into his BASIC compiler.
● Interfacing Stepper Motors
Prior to using stepper motor related statements, its connection and desired drive mode should be set up using DEFINE directives. There are eight available parameters to define the connection of A, B, C and D coils:
STEP_A_REG - defines the port where A coil is connected to
STEP_A_BIT - defines the pin where A coil is connected to
STEP_B_REG - defines the port where B coil is connected to
STEP_B_BIT - defines the pin where B coil is connected to
STEP_C_REG - defines the port where C coil is connected to
STEP_C_BIT - defines the pin where C coil is connected to
STEP_D_REG - defines the port where D coil is connected to
STEP_D_BIT - defines the pin where A coil is connected to
Coils A and C are actually parts of one single coil with common connection. The same is valid for B and D coil connections. There is also STEP_MODE parameter used to define the drive mode. If it is set to 1 (default) the motor will be driven in full-step mode. The value 2 should be used for half-step mode. The first basic statement that should be used is STEPHOLD. It will configure used pins as outputs and also energize A and B coils to fix the rotor in its initial position. For moving rotor in clockwise and counterclockwise directions there are STEPCW and STEPCCW statements available. Their first argument is the number of rotor steps that will be performed and it can be Byte data type constant or variable. The second argument defines the delay between consecutive steps expressed in microseconds by a Byte or Word data type variable or constant. If using STEPCW statement results in rotor movement in counterclockwise direction then connection settings for B and D coils should be exchanged. Here are two examples (the second example uses delays suitable for simulation in the simulator):
AllDigital
ADCON1 = 0x0E
Define STEP_A_REG = PORTB
Define STEP_A_BIT = 7
Define STEP_B_REG = PORTB
Define STEP_B_BIT = 6
Define STEP_C_REG = PORTB
Define STEP_C_BIT = 5
Define STEP_D_REG = PORTB
Define STEP_D_BIT = 4
Define STEP_MODE = 2
WaitMs 1000
StepHold
WaitMs 1000
Dim an0 As Word
loop:
Adcin 0, an0
an0 = an0 * 60
an0 = an0 + 2000
StepCW 1, an0
Goto loop
AllDigital
Define STEP_A_REG = PORTB
Define STEP_A_BIT = 7
Define STEP_B_REG = PORTB
Define STEP_B_BIT = 6
Define STEP_C_REG = PORTB
Define STEP_C_BIT = 5
Define STEP_D_REG = PORTB
Define STEP_D_BIT = 4
Define STEP_MODE = 2
WaitUs 300
StepHold
WaitUs 1000
loop:
StepCCW 16, 300
WaitUs 1000
StepCW 24, 300
WaitUs 1000
Goto loop