|
Register or have you forgotten your password?
|
|
|
| General chat about Amiga topics This forum is for conversations which are specifically "Amiga" related, but don't fit into other categories. Contents of this forum do appear on the main page, unlike Talk About. If a subject appears to be non-related, it will be moved to Talk About. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||||||||
|
Defender of the Faith
![]()
Join Date: Sep 2009
Location: Phila,Pa,USA
Posts: 1,110
|
Can someone tell me, can you turn off or on the printer port lines in amiga basic,
or some other programming language easily? I have an idea for a simple home automation project, I just need to be able to turn the lines of the printer port low or high. I know how to do this on a pc, but I never tried it on an amiga. Any help or doc files would be greatly appreciated. Thanks, Steven |
||||||||
|
|
|
|
|
#2 | ||||||||
|
Lifetime Member
![]()
|
Yes, but I don't know how. Basic can make system calls so you should be able to do it. I have a book on PC automation with basic programs but its PC based.
I'll pull it out and have a look but I guess it wont translate to Amiga Basic.
__________________
G E R T S Y A4000 040@25 16/2MB 8GB CF A2000 040@33 16/2MB 20GB BHD A1200 030@33 64/2MB 4GB CF A 500 000@07 2/1MB A590 1GB HD |
||||||||
|
|
|
|
|
#3 | ||||||||
|
Lifetime Member
![]()
|
Okay. No INP() or OUT() commands in Amiga Basic but I think this might help:
http://code.activestate.com/recipes/...in-read-mode-/ Arex or Python is the way to go. Be much faster than ABasic in any case. i guess.
__________________
G E R T S Y A4000 040@25 16/2MB 8GB CF A2000 040@33 16/2MB 20GB BHD A1200 030@33 64/2MB 4GB CF A 500 000@07 2/1MB A590 1GB HD Last edited by gertsy; 01-21-2012 at 04:57 PM.. Reason: way to got? |
||||||||
|
|
|
|
|
#4 | |||||||||
|
Cult Member
![]()
|
Quote:
Might check here http://aminet.net/package/misc/misc/3DHome There were some cool packages out there to control x-10 stuff, like EZHOME, if you can find it. maybe these have some insight on how they did it. article here thats interesting: http://www.hometoys.com/htinews/aug9...s/AmigaHA.html this gives a arexx port i think: http://aminet.net/package/driver/other/ARexX-10 which leads to this: http://marrickltd.com:8090/_files/Ma...MAN105_120.PDF Mech Last edited by mechy; 01-21-2012 at 05:03 PM.. |
|||||||||
|
|
|
|
|
#5 | ||||||||
|
Cult Member
![]()
Join Date: Feb 2002
Location: Antarctica
Posts: 940
|
There's an 8-bit data direction register (DDR) that controlls the direction of the 8 data lines plus an 8-bit register that you read/write input/output states.
There's also three "control" lines which can also be set in direction and read the input state or change the output state. All of these 8+3 lines can be individually set as inputs or outputs as you want them. Example in C: Code:
// Amiga register addresses
#define PARALLEL_DDR 0xBFE301 // System address of parallel port data direction register
#define PARALLEL_DATA 0xBFE101 // System address of paralled port data register
#define PAR_CTRL_DDR 0xBFD200 // System address of parallel port control line data direction register
#define PAR_CTRL_DATA 0xBFD000 // System address of parallel port control line data register
// Amiga register values
#define PARALLEL_DATA_OUTPUT 0xFF // Set parallel data direction to output
#define PARALLEL_DATA_INPUT 0x00 // Set parallel data direction to input
#define PARALLEL_CTRL_OUTPUT 0x07 // Set sel, pout, busy as outputs
/**********************************************************
write_data_latch
Writes single byte of data to programmer data latch
Arguments: unsigned char data_to_write
Return: none
Working:
**********************************************************/
void write_data_latch(unsigned char data_to_write)
{
// Write data to port
*parallel_ddr = PARALLEL_DATA_OUTPUT;
*parallel_data = data_to_write;
// Toggle data latch LE
*par_ctrl_data = *par_ctrl_data & (~DATA_LATCH_ON);
*par_ctrl_data = *par_ctrl_data | LATCH_IDLE;
}
Lines that are set as inputs will have a state of 1 or 0 depending on the 5V or 0V input state. If some lines are set as outputs, their current output state will be read in reads to 0xBFE101 That will work just like that, but to be "system friendly", you should declare to have the hardware resource open, then close it when the program exits. e.g. Code:
// Allocate the parallel port
if (MiscBase=OpenResource(MISCNAME))
{
pport_bits_owner = AllocMiscResource(MR_PARALLELBITS,"Your program name");
pport_port_owner = AllocMiscResource(MR_PARALLELPORT,"Your program name");
// If parallel port was successfully allocated
if ((pport_bits_owner==NULL) && (pport_port_owner==NULL))
{
// Here's where your program does its thing....
}
// Else the parallel port is busy
else
{
printf(" Can't allocate parallel port resources!\n");
printf(" The port may be in use by another application.\n\n");
}
// Clean up resources - do this when your program exits
if (pport_bits_owner==0){FreeMiscResource(MR_PARALLELBITS);}
if (pport_port_owner==0){FreeMiscResource(MR_PARALLELPORT);}
}
Should be easy enough do to in BASIC as well. Been a few years, but I guess it'd be something like: REM set data lines as outputs poke(hBFE301, hFF) REM set output line states to 10101010 poke(hBFE101, hAA) I can't remember how you state hex numbers in BASIC. Look on Aminet as well, Barry Walker wrote some demo stuff that shows how to do the same sort of thing in ARexx. Last edited by Castellen; 01-21-2012 at 05:13 PM.. |
||||||||
|
|
|
|
|
#7 | ||||||||
|
Defender of the Faith
![]()
Join Date: Sep 2009
Location: Phila,Pa,USA
Posts: 1,110
|
Thanks for everyone's help...
Today, I found out how to use the joystick ports as digital inputs and can read them in amiga basic fine. This means an amiga can make quite an effective burglar alarm... On the printer port... I am sure what I need to do can be done, it will require some research. Essentially, I want to hook leds to the the 8 lines and be able to turn them on or off in basic or some other language. I can use some photocells and relays and other electronics to turn on and off whatever I want. I thought this might be a cool use for an a500 I have sitting around not doing much. I had some old hardware projects like this saved from magazines in a binder somewhere, wish I could find that binder now! Steven |
||||||||
|
|
|
|
|
#8 | ||||||||
|
Master Sock Abuser
|
@Haywirepc
Slightly off topic, but have you looked at the Arduino? That might be a more fun way to get started
__________________
My iPhone Game: Puny Humans - http://itunes.apple.com/gb/app/puny-...362230281?mt=8 |
||||||||
|
|
|
|
|
#9 | ||||||||
|
Technoid
![]()
Join Date: Nov 2005
Posts: 152
|
@haywirepc
It would be probably easier to use the serial port for your Projekt. You can use the Standard System APIs and with a serial Relay card like this: http://www.velleman.eu/products/view/?id=351282 You can switch whatever you like, without destroying your Amiga. |
||||||||
|
|
|
|
|
#10 | ||||||||
|
Defender of the Faith
![]()
Join Date: Sep 2009
Location: Phila,Pa,USA
Posts: 1,110
|
http://www.velleman.eu/products/view/?id=351282
Did you mean this? Do you think I can control that via the amiga's serial ports by sending serial strings through basic? I saw something like that before where you'd send 8 characters through the serial port (one for each relay). like 00000000 - all off 11111111 - all on. 00000001 - all off but 8 and so on... Bloodline, yes I just recently saw those arduino boards. I'm very behind on microcontrollers, last one I played with alot was a basic stamp 2. That arduino is like having 3 or 4 basic stamp 2's in one, its really slick. I'm a bit intimidated by the programming language it uses, but I think it may be worth learning for all the options that tiny board has... Thanks for everyone's suggestions. How do you control leds, lights, relays, whatever using an aimga? Any suggestions welcome! Steven |
||||||||
|
|
|
![]() |
| Bookmarks |
| Tags |
| control , port , printer |
| Thread Tools | |
| Display Modes | |
|
|