Shop OBEX P1 Docs P2 Docs Learn Events
serial inkjet printer — Parallax Forums

serial inkjet printer

maadmaad Posts: 28
edited 2008-02-12 07:27 in BASIC Stamp
I bought the 96 dpi serial inkjet kit but I have some issues, I attach this to a basic stamp bs2p and download from your site the simple_print_data example code, it prints everytime I push the reset button from my supercarrierboard, but Im trying to make it work with a pushbutton, I download a manual on how to use microcontrollers and apply an example on using pushbuttons, the pushbutton only works one time, if i want to print again i need to reset it, but I dont know whats wrong with my code language, and I cannot find a customer who has posted a project like this, could you please give me a hand with this, I"ll appreciatte it, thanks. here is my code:


[noparse][[/noparse]code]'
[noparse][[/noparse] I/O Definitions ]

Inkjet PIN 15 ' to HP driver


'
[noparse][[/noparse] Constants ]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T9600 CON 84
#CASE BS2SX, BS2P
T9600 CON 240
#CASE BS2PX
T9600 CON 396
#ENDSELECT

SevenBit CON $2000
Inverted CON $4000
Open CON $8000
Baud CON Open + T9600


Prompt CON ">" ' prompt from HP driver
STX CON 2 ' start of text
ETX CON 3 ' end of text
Esc CON 27 ' escape


'
[noparse][[/noparse] Variables ]

msgPntr VAR Word ' points to msg in EE
char VAR Byte ' character to print


'
[noparse][[/noparse] EEPROM Data ]

Msg1 DATA STX, "TESTING", ETX


'
[noparse][[/noparse] Main Routine ]

DO

msgPntr = Msg1
GOSUB Print_String
SEROUT Inkjet, Baud, [noparse][[/noparse]Esc, "C", 15] ' intercolumn delay 1.5 ms
SERIN Inkjet, Baud, 500, No_Inkjet, [noparse][[/noparse]WAIT(Prompt)]
END

LOOP
'
[noparse][[/noparse] Subroutines Print_String]

No_Inkjet:
' handle no response from Inkjet here


Print_String:

DO

IF (IN0 = 1 ) THEN
READ msgPntr, char ' get character from msg
SEROUT Inkjet, Baud, [noparse][[/noparse]char] ' send to print driver
msgPntr = msgPntr + 1 ' point to next char ' point to next char


ENDIF

LOOP UNTIL (char = ETX) ' done at ETX

RETURN

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-02-12 04:43
    Maad -

    There are a couple of problem areas in your program. The reason it's stopping is due to the END statement. The END statement should be used ONLY at the actual end of the program, and no where else.

    Without seeing how the pushbutton switch is wired, there is no way for us to know whether it will work or not. Is it a maintained switch, or a momentary switch and is it normally OPEN or normally CLOSED?

    Presently IF you have a maintained switch kept in the ON position that will permit the program to continue until the switch is turned off.

    Last, it doesn't appear as though you have made any provision for printing multiple lines, or multiple pages. Normally, with most printers, one issues a CR (carriage return) and/or a LF (line feed) at the end of the physical line of data (after the ETX), to advance the platen, in preparation to print the next line of data. If the paper isn't a paper tape, then the same should be done at the end of the physical page, and the platen adjusted to feed the next page.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Genius is one percent inspiration and ninety-nine percent perspiration."

    Thomas Alva Edison
  • maadmaad Posts: 28
    edited 2008-02-12 04:59
    the pushbutton is a momentary button normally open with a pull down resistor, so when the button is not pressed is sending a zero to P0 and sends 1 when momentary closed, when I do this it prints "TESTING" but when I pressed again it doesn respond.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-02-12 05:22
    Maad -

    Have you removed the END statement as I suggested, or are you speaking of how it worked prior to any of the changes mentioned? If the latter, please remove the END statement, and we can go from there in troubleshooting the program. Having the END statement in there will produce the results you are presently seeing, as regards the pushbutton switch.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Genius is one percent inspiration and ninety-nine percent perspiration."

    Thomas Alva Edison
  • maadmaad Posts: 28
    edited 2008-02-12 05:37
    I havent remove the end statement yet, I just described how it is working, if I remove the end statement i receive this message "expect a label, variable,instruction or endif. I cannot remove it!
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-02-12 06:10
    Maad -

    I suspect you tried to remove the ENDIF statement just before the LOOP statement in the Print_String routine. I copied your program exactly as shown, removed the END (NOTE: NOT ENDIF) statement from what is indicated as the Main Routine, ran it back through the PBASIC Stamp Editor and there were no error messages.

    However, when I removed the ENDIF statement in the Print_String routine, and ran it back through the PBASIC Stamp Editor, I DO get the error you are suggesting.

    So long as that END statement in in there, the way the program is presently written, you will continue to have the problem you originally presented to us.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Genius is one percent inspiration and ninety-nine percent perspiration."

    Thomas Alva Edison
  • maadmaad Posts: 28
    edited 2008-02-12 07:27
    Yeessss!!! thank you so much, that did the trick
Sign In or Register to comment.