amiga.org
     
iconAll times are GMT -6. The time now is 01:01 AM. | Welcome to Forum, please register to access all of our features.

» Amiga.org » Amiga computer related discussion » General chat about Amiga topics » Printer port control?

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.

Reply
 
Thread Tools Display Modes
Old 01-21-2012, 02:27 PM   #1
haywirepc
Defender of the Faith
Points: 9,305, Level: 64 Points: 9,305, Level: 64 Points: 9,305, Level: 64
Activity: 1% Activity: 1% Activity: 1%
 
haywirepc's Avatar
 
Join Date: Sep 2009
Location: Phila,Pa,USA
Posts: 1,110
Default Printer port control?

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
haywirepc is offline   Reply With Quote
Old 01-21-2012, 04:35 PM   #2
gertsy
Lifetime Member
Points: 10,469, Level: 68 Points: 10,469, Level: 68 Points: 10,469, Level: 68
Activity: 7% Activity: 7% Activity: 7%
 
gertsy's Avatar
 
Join Date: May 2006
Location: Melbourne, Oz
Posts: 1,532
Default Re: Printer port control?

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
gertsy is offline   Reply With Quote
Old 01-21-2012, 04:55 PM   #3
gertsy
Lifetime Member
Points: 10,469, Level: 68 Points: 10,469, Level: 68 Points: 10,469, Level: 68
Activity: 7% Activity: 7% Activity: 7%
 
gertsy's Avatar
 
Join Date: May 2006
Location: Melbourne, Oz
Posts: 1,532
Default Re: Printer port control?

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?
gertsy is offline   Reply With Quote
Old 01-21-2012, 04:59 PM   #4
mechy
Cult Member
Points: 11,190, Level: 69 Points: 11,190, Level: 69 Points: 11,190, Level: 69
Activity: 1% Activity: 1% Activity: 1%
 
mechy's Avatar
 
Join Date: Apr 2005
Location: Texas,usa
Posts: 795
Send a message via AIM to mechy Send a message via MSN to mechy
Default Re: Printer port control?

Quote:
Originally Posted by haywirepc View Post
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

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..
mechy is offline   Reply With Quote
Old 01-21-2012, 05:09 PM   #5
Castellen
Cult Member
Points: 9,990, Level: 66 Points: 9,990, Level: 66 Points: 9,990, Level: 66
Activity: 5% Activity: 5% Activity: 5%
 
Join Date: Feb 2002
Location: Antarctica
Posts: 940
Default Re: Printer port control?

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;
}
Reading input lines is as simple as reading from system address 0xBFE101

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..
Castellen is offline   Reply With Quote
Old 01-22-2012, 03:36 AM   #6
Zac67
Kindred of Babble-on
Points: 12,503, Level: 73 Points: 12,503, Level: 73 Points: 12,503, Level: 73
Activity: 15% Activity: 15% Activity: 15%
 
Zac67's Avatar
 
Join Date: Nov 2004
Location: Erlangen, Germany
Posts: 2,862
Blog Entries: 4
Default Re: Printer port control?

Keep in mind that since there's no resource tracking, the parallel port is likely to stay allocated if you break the program.
Zac67 is offline   Reply With Quote
Old 01-22-2012, 03:44 AM   #7
haywirepc
Defender of the Faith
Points: 9,305, Level: 64 Points: 9,305, Level: 64 Points: 9,305, Level: 64
Activity: 1% Activity: 1% Activity: 1%
 
haywirepc's Avatar
 
Join Date: Sep 2009
Location: Phila,Pa,USA
Posts: 1,110
Default Re: Printer port control?

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
haywirepc is offline   Reply With Quote
Old 01-22-2012, 04:05 AM   #8
bloodline
Master Sock Abuser
Points: 37,268, Level: 100 Points: 37,268, Level: 100 Points: 37,268, Level: 100
Activity: 11% Activity: 11% Activity: 11%
 
bloodline's Avatar
 
Join Date: Mar 2002
Location: London, UK
Posts: 11,666
Blog Entries: 3
Default Re: Printer port control?

@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
bloodline is offline   Reply With Quote
Old 01-22-2012, 05:11 AM   #9
Heinz
Technoid
Points: 6,382, Level: 52 Points: 6,382, Level: 52 Points: 6,382, Level: 52
Activity: 2% Activity: 2% Activity: 2%
 
Heinz's Avatar
 
Join Date: Nov 2005
Posts: 152
Default Re: Printer port control?

@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.
Heinz is offline   Reply With Quote
Old 01-22-2012, 04:19 PM   #10
haywirepc
Defender of the Faith
Points: 9,305, Level: 64 Points: 9,305, Level: 64 Points: 9,305, Level: 64
Activity: 1% Activity: 1% Activity: 1%
 
haywirepc's Avatar
 
Join Date: Sep 2009
Location: Phila,Pa,USA
Posts: 1,110
Default Re: Printer port control?

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
haywirepc is offline   Reply With Quote
Reply

Bookmarks

Tags
control , port , printer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump