Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:44 06 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Parallel port

Author Message
kermess
Regular Member

Joined: 04/04/2013
Location: Spain
Posts: 45
Posted: 09:46pm 26 Jul 2016
Copy link to clipboard 
Print this post

Hi,

I need to manipulate ten bits in parallel and I think this is the command for this.

PORT(start, nbr [,start, nbr]…) = value

I want to move a five-phase stepper motor with 5 chips of this type L9110H
These are the ten bits in order according to my scheme.
15, 16, 23, 2, 4, 5, 6, 7, 9, 10
This is the minimum program

Setpin 15, dout
Setpin 16, dout
Setpin 23, dout
Setpin 2 dout
Setpin 4 dout
Setpin 5, dout
Setpin 6 dout
Setpin 7 dout
Setpin 9 dout
Setpin 10 dout

do
Port (15,2,23,1,2,1,4,4,9,2) = & B0101010101
Pause 200
Port (15,2,23,1,2,1,4,4,9,2) = & B1010101010
Pause 200
'Flicker bits
Loop

explanation
15, 2 = 15,16
23,1 Only 23
2,1 Only 2
4,4 = 4, 5, 6, 7
9.2 = 9, 10

RESULT
Error: Unknown command:
Question … ? ... .. Has anyone used this command.
What is the correct way to use ..?

I am using Windows 10.
PIC32MX170F
MIcromite 5.1 V.

Saludos
David.
from Barcelona.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 09:51pm 26 Jul 2016
Copy link to clipboard 
Print this post

Hi David,

In your code, do you have a space character between the '&' and the 'B' as shown above?

If so, then this is likely to be your issue

WW
 
kermess
Regular Member

Joined: 04/04/2013
Location: Spain
Posts: 45
Posted: 07:57pm 27 Jul 2016
Copy link to clipboard 
Print this post

Hello WW.
It seems to be separate but in the code within the program all together.
Another way in which I tried the code is this:
port (15,1,16,1,23,1,2,1,4,1,5,1,6,1,7,1,9,1,10,1)=&B0101010101
port (15,2,23,1,2,1,4,4,9,2)=&B0101010101 .... This looks good.
And so it is exactly.The same error.

Thank you.
David
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 09:36pm 27 Jul 2016
Copy link to clipboard 
Print this post

You have a space between port and (

port (


Jim
VK7JH
MMedit
 
kermess
Regular Member

Joined: 04/04/2013
Location: Spain
Posts: 45
Posted: 10:29pm 27 Jul 2016
Copy link to clipboard 
Print this post

YES.

I think that this construction would be normal,

port (15,2,23,1,2,1,4,4,9,2)=&B1001010101

This is the error.
Error: Unknown command

Without space.
port(15,2,23,1,2,1,4,4,9,2)=&B1001010101

run ok ..... but also a different error.
When you run the line in question.

!!! Reset ¡¡¡
This is the result.
Micromite MKII MMBasic Ver 5.1
Copyright 2011-2016 Geoff Graham


...... David







 
Greg Fordyce
Senior Member

Joined: 16/09/2011
Location: United Kingdom
Posts: 153
Posted: 12:44am 28 Jul 2016
Copy link to clipboard 
Print this post

Try using this command as a test.

port(15,2)=&B10

Maybe there is a limit to the number of arguments the port command can handle. If that works gradually increase the arguments until you find the limit.
 
kermess
Regular Member

Joined: 04/04/2013
Location: Spain
Posts: 45
Posted: 10:42am 28 Jul 2016
Copy link to clipboard 
Print this post

Hi, Greg
No, it does not work
I have tried different ways to test the port and these are the results.

'Port(15,2)=&B10 ' Pin 15 not output
'port (15,2)=&B10 ' Error: Unknown command
'Port(16,1)=&B1 ' Pin 16 not output
'port (16,1)=&B1 ' Error: Unknown command
'port (23,1)=&B0 ' Error: Unknown command
'port (4,4)=&B0110 ' Error: Unknown command

--------------
This is what I need.
' port (15,2,23,1,2,1,4,4,9,2)=&B1010101010
--------------

This works fine, but I think it is much slower
'pin(15)=1:pin(16)=0:pin(23)=0:pin(2)=0:pin(4)=0
'pin(5)=1:pin(6)=0:pin(7)=1:pin(9)=0:pin(10)=1
--------------
Muchas gracias.
David
 
Greg Fordyce
Senior Member

Joined: 16/09/2011
Location: United Kingdom
Posts: 153
Posted: 11:05am 28 Jul 2016
Copy link to clipboard 
Print this post

  Quote  Port(15,2)=&B10 ' Pin 15 not output


Did you set pins 15 and 16 as digital outputs first before trying the command?
 
kermess
Regular Member

Joined: 04/04/2013
Location: Spain
Posts: 45
Posted: 08:48pm 28 Jul 2016
Copy link to clipboard 
Print this post

Yes ....

SetPin 15,dout
SetPin 16,dout
SetPin 23,dout
SetPin 2,dout
SetPin 4,dout
SetPin 5,dout
SetPin 6,dout
SetPin 7,dout
SetPin 9,dout
SetPin 10,dout

I tried it with definitions previously and also without defining them.
For try everything.

This is the minimum expression of the program.
--------------
SetPin 15,dout
SetPin 16,dout

Print "Mini_port.bas"

port (15,2)=&B10

Print "END"
--------------
Error: Unknown command
--------------

Thank you
David.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 10:24pm 28 Jul 2016
Copy link to clipboard 
Print this post

Can you update to V5.2
I don't have any 5.1 available but it runs OK on 5.2 (provide you get rid of that space between port and (

> AUTOSAVE
SetPin 15,dout
SetPin 16,dout

Print "Mini_port.bas"

port(15,2)=&B10

Print "END"
Saved 88 bytes
> RUN
Mini_port.bas
END
>



Jim
VK7JH
MMedit
 
kermess
Regular Member

Joined: 04/04/2013
Location: Spain
Posts: 45
Posted: 05:57am 27 Sep 2016
Copy link to clipboard 
Print this post

Hello, I upgraded to version 5.2 and the "PORT" command works correctly.
Thank you very much to all.
David.
 
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 07:50am 27 Sep 2016
Copy link to clipboard 
Print this post

Hi kermess;

Just a technical detail.
The port command is much faster at sending the bits out
than using individual pin commands.
However.
They aren't switched simultaneously as with a normal
parallel port.

There is a bit of delay, a few uS or so, between the bits.
This is not a problem with mechanical things like
stepper motors and such.

To get true parallel port switching an external clocked
register would be required. Of course even a parallel port
isn't truly synchronous as there are propagation delays.

redrok
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025