|
|
| Author |
Message |
vesteve
Joined: 09 Oct 2009
Posts: 3
Location: Spain
|
|
Posted: 11 October 2009, 20:18 PM Post subject: Code for ZX-328n Working as slave of a PC with VB6 |
|
|
I am new with Z Processors and some idea programming in VB6.
I need to use a Zn-128 as interface to control a machine.
PortB will be used as output (Reles, light, etc...)
PortD will be used as Digital Input as Buttons, etc...
PortC will be used as A/D Reader for Temperature, Humidity, etc..
The Main program will be made by VB6, I will use the power of PC to store values, display, control, etc..
And, This is my question:
How Can I Get the values of PortC and PortD into VB6 variables?
How I can write values into PortB from VB6 variable?
Maybe you will consider these questions very child, but I have never work with RS232.
Thanks for your attention. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 11 October 2009, 21:22 PM Post subject: |
|
|
There is no "standard" way to do what you've described. Essentially, you have to invent a protocol for sending data back and forth between the PC and the ZX. For example, you might send data to the PC in the form | Code: | | <element name> = <value> CRLF | where <element name> is a sequence of characters to identify the element whose value you're sending and <value> represents the value itself. (CRLF is a carriage return/linefeed combination.) The value could be in decimal form, hexadecimal form, real number form, logic form (e.g. TRUE or FALSE), symbolic form or any other form you find useful.
Once you've decided on the format, the only thing left to do is the coding. An Internet search will produce quite a bit of information on the subject of sending and receiving data in VB6 via the serial port. |
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 657
|
|
Posted: 12 October 2009, 4:03 AM Post subject: |
|
|
That's also called tagname/value
kind of like XML |
|
| Back to top |
|
 |
vesteve
Joined: 09 Oct 2009
Posts: 3
Location: Spain
|
|
Posted: 12 October 2009, 11:54 AM Post subject: |
|
|
OK, thats I was thinking about the way to work.
But One question.
Do I must open the RS232 in both PC and ZN?
And keep in both in receiving data?
An when have an interrupt as button, etc, or controlled by time, then send the new values from one to another by rs232? |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 12 October 2009, 18:37 PM Post subject: |
|
|
| vesteve wrote: | | Do I must open the RS232 in both PC and ZN? | In order to send data on a serial channel on a ZX device, the serial channel must be open. The Com1 channel is opened automatically (at 19.2K baud) and you can send data most easily by using Debug.Print or Console.Write. If you want to use other serial channels (e.g. Com3 through Com6) you must define the configuration (DefineCom), initialize the queues (OpenQueue) and then open the serial channel (OpenCom). Once that is done, you send data by adding it to the channel's transmit queue.
On the PC side, you'll need to open a serial channel before you can use it. How that is done depends on whether you're using some VB code that someone else wrote or you're using the Windows system calls directly. Again, an Internet search will provide lots of information on this topic.
| vesteve wrote: | | An when have an interrupt as button, etc, or controlled by time, then send the new values from one to another by rs232? | You can implement a strategy where the ZX only sends data when requested by the PC. Alternately, you can implement a strategy where the ZX sends data periodically or immediately when it becomes available. You can also implement a mixed strategy where some data is sent only on demand while other data is sent based on the occurrence of an event. |
|
| Back to top |
|
 |
|