Parallel Com Port

hawkeyetim

Member
Licensed User
Longtime User
Hi Guys
Is it possible to control the input and output of the printer port using basic4ppc as i wish to control some stepping motors. I was wondering if the serial library would do the job or is that only for the serial port. :sign0104:

Thanks
Tim
 
Last edited:

RandomCoder

Well-Known Member
Licensed User
Longtime User
Hi hawkeyetim,

You can't control the parallel port directly, but you could use a serial to parallel converter. I've done this on a print capture program and it works a treat. Some converters are bi-directional and allow to send and recieve data.

Regards,
RandomCoder.

PS If you shop round you can find then relatively cheaply Aten SXP-500 serial to parallel converter on eBay (end time 11-Aug-09 23:03:52 BST)
THIS IS BY NO WAY AN ENDORSEMENT TO BY FROM THIS SELLER!!!!!
 

taximania

Well-Known Member
Licensed User
Longtime User
Hi Hawk.
How about using a microchip pic instead of the parallel port.
There's more pins available, and there's bound to be stepper motor
control software already written for a pic.

Infrared, bluetooth and serial port control are all available from Basic4ppc.

See my website page for more details.
 

hawkeyetim

Member
Licensed User
Longtime User
Thanks Guys
Think am off down the usb controller route as I've found some descent hardware to control the stepping motors with a dll library for control but whether its compatible with basic4ppc i don't know as its written for C so i might have to learn a new language (bugger):sign0080:

Hawk
 

hawkeyetim

Member
Licensed User
Longtime User
not really sure its says the following

Although the DLL was written in „C‟ it can be used (called) by programs written in a number of popular languages, the most popular of which is BASIC (Visual BASIC). Described below are the techniques to use the DLL in Visual Basic and C++. If you program in another language please refer to your compiler manual on the details of calling a C++ library function, which will be very similar to the techniques described below.

the web address is Stepper Motor Control from a USB Port
 

hawkeyetim

Member
Licensed User
Longtime User
think am going to order one later and hopfully it will work will basic4ppc and desktop if not its visual basic time. will let you know what happens.
 

Ariel_Z

Active Member
Licensed User
I created a simple Basic4ppc wrapper for the dll. This exposes the needed functions (according to their documentation) and should work. NOTE: I did not test it, so please let me know (you can also by PM or [email protected]) if it works.

What you need to do:
1. Download.
2. Place in the application folder.
3. Place the DLL you got from them (you bought) in the same folder.
4. In Basic4ppc, add StpMotor4ppc.dll to your program and add an object with the same name (unfamiliar with libraries? see libraries tutorial).
5. I called mine stp, and so you now can write:

B4X:
stp.New1
   stp.InitStp
   stp.RunMotor1(10, 10, 10, 5)
   stp.StopMotor1(5)

Let me know if it works!
 

Attachments

  • StpMotor4ppc.zip
    2 KB · Views: 174
Last edited:

hawkeyetim

Member
Licensed User
Longtime User
what a brillitant forum this is.
thanks Ariel_Z :sign0098:.
i've ordered all my parts and with the help of ariel_z and everyone else i should have working motors soon. will post again once everything is in place and hopfully working

Hawk
 

hawkeyetim

Member
Licensed User
Longtime User
Will send pics when i receive the stepping motors have only tested the outputs with LED's at the moment. Should get them in the next few days.
I'll probably be here (forum) quite a bit over the next few months to get my project off the ground.

Hawk
 

hawkeyetim

Member
Licensed User
Longtime User
Hi Ariel_Z

Have a problem with the GetCurrentStatus command which i can not get to work. It comes back with a weird error any help appreciated as always.
All the other commands work fine.

Thanks


Code :
Sub Globals
'Declare the global variables here.
Dim m1,m2,s1,s2,i
End Sub

Sub App_Start
stp.New1
stp.InitStp
stp.RunMotor1(1000,10,0,0)
stp.GetCurrentStatus(m1,m2,s1,s2,i)


End Sub


Error :
An error ocurred in sub main.app_start

line number: 10

stp.GetCurrentStatus(m1,m2,s1,s2,i)
error description
Attempted to read or write protected memory. This is often an
indication the other memory is corrupt.
 

agraham

Expert
Licensed User
Longtime User
I'm afraid that it's a library error. Ariel needs to recompile the library with a different signature for GetCurrentStatus, the parameters to that function should be passed by reference but he is passing them by value. He will either need to return an array with the values or add a few properties to pass the information back into Basic4ppc as it cannot cope with parameters passed by reference to a library.
 

Ariel_Z

Active Member
Licensed User
Agraham is right.
I did what he said. What we end up with right now is this: Instead of the GetCurrentStatus function you now have 5 different functions. They are, M1Active, M1Steps, M2Active, M2Steps, and Inputs. Use them instead of the original method.
Each one calls the method separately when called. Depending on what you plan to do, there might be a small performance loss (I guess not). If so, let me know and I'll create something a bit faster (though less simple, that's why I decided to do it like that).
 

Attachments

  • StpMotor4ppc.zip
    2 KB · Views: 181

hawkeyetim

Member
Licensed User
Longtime User
Thanks Guys for the quick reply and solution.
Won't be able to test until tomorrow now but will let you know how it goes.
:sign0060:
Thanks Again
 

hawkeyetim

Member
Licensed User
Longtime User
Hi YA
Just finished testing and all commands are work absolutely fine. Regarding performance no issue at the moment it takes about 50/1000 of a second to call the command which should be plenty fast enough.

Thanks Ariel_Z


here is also a link to video i posted on youtube just showing motors spinning (really sad i know)

YouTube - telescope control step 1
 
Top