![]() |
Forum Index : Microcontroller and PC projects : Parallel port
Author | Message | ||||
kermess Regular Member ![]() Joined: 04/04/2013 Location: SpainPosts: 45 |
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 KingdomPosts: 2932 |
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: SpainPosts: 45 |
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: AustraliaPosts: 6269 |
You have a space between port and ( port (
Jim VK7JH MMedit |
||||
kermess Regular Member ![]() Joined: 04/04/2013 Location: SpainPosts: 45 |
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 KingdomPosts: 153 |
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: SpainPosts: 45 |
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 KingdomPosts: 153 |
Did you set pins 15 and 16 as digital outputs first before trying the command? |
||||
kermess Regular Member ![]() Joined: 04/04/2013 Location: SpainPosts: 45 |
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: AustraliaPosts: 6269 |
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: SpainPosts: 45 |
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 StatesPosts: 209 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |