Hi!
I am experiencing problems in using arrays within a project.
I am writing a project to use a relays board via USB interface, and I need to pass arrays between modules. However, I am missing something and I can't do it. Probably, it is a "stupid" question , is it possible to declare an array as EXTERN and use it in different modules within a project?
Thanks so much
Greetings from Como (Italy)
Yours Carlo
The best way to manage global variables between "modules" is to use the PROJECTGLOBAL command.
Create a source file for all of your global variables, named something convenient like "prglobals.eba"
Add this file to the project. The contents of this file might look like:
PROJECTGLOBAL "on"
int MyArray[1000]
float gTotal
PROJECTGLOBAL "off"
Then in any file you want to have access to the variables just use an include statement:
$include "prglobals.eba"
The compiler then takes care of all the "extern name as type" statements you would normally have to type. When it sees the PROJECTGLOBAL "on" statement during an $include it knows to define all the variabls that follow as external, and knows they will be located as a separate module compiled as a project file.
Paul.
Dear Paul :
works great! Thanks so much for answering me late at night, probably 2 or 3 o'clock in the US!.
Unfortunately, I am a chemist, not an IT professional, and, although I've been invoved in computers since the old days of AppleII and Sinclair Spectum/Timex, my knowledge in advanced programming techniques is somewhat limited. University teaching in instrumental analytical chemistry is my primary job, and few time is left to me for developing new PC-based instrumentation.
Yours Carlo
Hi Carlo,
It's good to hear you are applying Emergence to real-time control applications.
If you ever have a minute to spare .. :) it would be highly educational if you could enlighten folk here how to interface the program via USB to control equipment.
all the best, :)
Graham
Hi !
Most USB evices may be seen as virtual COM port (VCP) by istalling suitable drivers. In my specific case of real-time control of valves or other appliances in my chemistry lab, I'm using a PIC-based USB board called UBW (USB Bit Whacker) by Brian Schmalz (http://greta.dhs.org/UBW/index.html). I actually bought it by SparkFun (http://www.sparkfun.com/commerce/product_info.php?products_id=762).
I consider UBW a great product, it will show up as an RS232 Com port when attached (and powered by) USB port! You control the individual I/O pins on the PIC through simple serial commands. For example, "po,b,1,1" is used to turn on pin #1 of port B, and "po,b,1,0" for tutning it off.
Simple electronics is then required to interface with external wordls, e.g. power relais topower loads, optocouplers and so on.
Actually I started using UBW in a large project on electrochemical instrumentation written in Liberty Basic. I am now involved in a new project, for controlling valves and heaters in a microscale reactor. I started using EBASIC, since I realized it is more suitable for handling multiple timers in real-time control of valves.
The project is still at an initial stage, and I'll keep you informed on future developments.
Keep in touch
Carlo