Re: Kretskortstillverkning, inkjet direct to PCB (Epson S21)
Postat: 29 augusti 2010, 16:41:09
Byt kretskort mellan patronerna?, så att den tror att gul är svart och tvärtom osv.. tills du hittar någon användbar kombination.
Svenskt forum för elektroniksnack.
https://elektronikforumet.com/forum/
Det var just det som hände vid mitt första försök. Bläcket försvann i etsbadet trots att det inte gick att få bort med vatten (det ska tydligen inte gå att få bort med aceton heller).scc_11067 says: "[using Durabright inks] ... I switched to ferric chloride and get really good results. I am currently using durabrite yellow with really good etch's Could use durabrite magenta, but the ink bunches up on the board if not dried instantly. The persulfates just lift the ink off the board."
Kod: Markera allt
/*
-- paperemulator.c
--
-- paper emulator for EPSON S21
--
-- Copyright (C) 2010 rehnmaak -- www.elektronikforumet.com
-- http://elektronikforumet.com/forum/viewtopic.php?f=17&t=44340
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Lesser General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
*/
// This program emulates the paper in a EPSON S21 inkjet printer with a ATmega328P
// PORT B0 -- phase A to the paper feed stepper motor
// PORT B1 -- phase B to the paper feed stepper motor -- not used currently
// PORT D3 -- test point 1 is H for one cycle when the motor has taken one stepper
// PORT D4 -- test point 2 is H as long as the stepper is running. TP2 goes low if motor stops longer than 10ms.
// PORT D5 -- relay, activated 1660ms after paper sensor was activated.
// PORT D6 -- paper sensor. Activated after 400 steps of continous stepping. Connected to 2n7002 mosfet gate. Drain connected to printer
// PORT D7 -- LED. Active as long as motor is connected.
//
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <string.h>
#include "uart.h"
#define LED 0x80 //PORTD
#define PD 0x40
#define REL 0x20
#define TP1 0x10
#define TP2 0x08
#define PH1 0x01 //PORTB
#define PH2 0x02
char timerevt;
int timercnt;
__fuse_t __fuse __attribute__((section (".fuse"))) =
{
// .low = LFUSE_DEFAULT,
// .high = (FUSE_BOOTSZ0 & FUSE_BOOTSZ1 & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN),
.low = (FUSE_CKSEL3),
.high = HFUSE_DEFAULT,
.extended = EFUSE_DEFAULT,
};
ISR(TIMER0_COMPA_vect)
{
timercnt++;
timerevt=1;
}
FILE uart_str = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
int main ()
{
char ph1;
char ph1_old;
int ph1_cnt;
int step;
int old_step;
char feed;
char eject;
char relay;
int relaycnt;
char ch;
int n;
uart_init();
stdout = stdin = &uart_str;
stderr = stdout;
printf("Hello paper emulator!\n");
//enable port D
DDRD = LED | PD | REL | TP1 | TP2;
PORTD = PD;
//enable timer
TCCR0A = 0x02; //CTC mode
TCCR0B = 0x05; //div by 1024
OCR0A = 156; //100Hz
TIMSK0 = 0x02; //OCIE0A output compare A interrupt
ph1 = PINB & PH1;
ph1_cnt = 0;
step = 0;
old_step = 0;
feed = 0;
relay = 0;
eject = 0;
relaycnt = 0;
n = 0;
sei(); // Enable global interrupts
for(;;)
{
//check uart every 1000:nd time
n++;
if (n==1000)
{
n = 0;
ch = uart_getc();
//if 'f' was pressed activate paper detector after 1s
if (ch=='f')
{
printf("waiting for paper feed\n");
feed=1;
relay=0;
eject=0;
step=0;
PORTD &= ~LED; //turn off led
PORTD |= PD; //no paper
PORTD |= REL; //turn off motor
}
// if 'q' was pressed deactivate paper detector
if (ch=='q')
{
printf("stop feeding paper\n");
feed=0;
step=0;
eject=0;
PORTD |= PD;
PORTD &= ~REL; //turn on motor
}
}
//if we had a timer interrupt
if (timerevt)
{
//turn on motor after 1660ms
//after PD active
if (relay)
{
relaycnt++;
if (relaycnt==166) //1660ms
{
relay = 0;
PORTD |= LED; //turn on led
PORTD &= ~REL; //turn on motor
eject = 1;
}
}
//if paper feed detection is active
//wait for 400 consecutive steps
//before activating PD sensor
if (feed)
{
//activate PD after 400 steps (0.67s)
if (step>400)
{
feed=0;
relay=1;
relaycnt=0;
PORTD &= ~PD;
}
}
//deactivate PD after 2000 consecutive steps
if (eject)
{
if (step>2000)
{
eject=0;
PORTD |= PD; //deactive PD sensor
}
}
//check if stepper has moved in the last 10 ms
//if not reset step counter
if (old_step==step)
{
step=0;
PORTD &= ~TP2;
}
else
{
PORTD |= TP2;
}
old_step = step;
timerevt = 0;
}
//get phase voltage
ph1_old = ph1;
ph1 = PINB & PH1;
//measure how long the drive pulse is
if (ph1_old == ph1)
{
ph1_cnt++;
PORTD &= ~TP1;
}
else
{
//we enter here if the phase voltage changed
//if the drive pulse is longer than 100
//we have a step
if (ph1_cnt > 100)
{
step++;
PORTD |= TP1;
}
ph1_cnt = 0;
}
}
return 0;
}
Kod: Markera allt
//uart.c
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
* ----------------------------------------------------------------------------
*
* Stdio demo, UART implementation
*
* $Id: uart.c,v 1.1 2005/12/28 21:38:59 joerg_wunsch Exp $
*/
#include "defines.h"
#include <stdint.h>
#include <stdio.h>
#include <avr/io.h>
#include "uart.h"
/*
* Initialize the UART to 9600 Bd, tx/rx, 8N1.
*/
void
uart_init(void)
{
#if F_CPU < 2000000UL && defined(U2X)
UCSRA = _BV(U2X); /* improve baud rate error by using 2x clk */
UBRRL = (F_CPU / (8UL * UART_BAUD)) - 1;
#else
UBRRL = (F_CPU / (16UL * UART_BAUD)) - 1;
#endif
UCSRB = _BV(TXEN) | _BV(RXEN); /* tx/rx enable */
}
/*
* Send character c down the UART Tx, wait until tx holding register
* is empty.
*/
int
uart_putchar(char c, FILE *stream)
{
if (c == '\a')
{
fputs("*ring*\n", stderr);
return 0;
}
if (c == '\n')
uart_putchar('\r', stream);
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return 0;
}
/*
* Receive a character from the UART Rx.
*
* This features a simple line-editor that allows to delete and
* re-edit the characters entered, until either CR or NL is entered.
* Printable characters entered will be echoed using uart_putchar().
*
* Editing characters:
*
* . \b (BS) or \177 (DEL) delete the previous character
* . ^u kills the entire input buffer
* . ^w deletes the previous word
* . ^r sends a CR, and then reprints the buffer
* . \t will be replaced by a single space
*
* All other control characters will be ignored.
*
* The internal line buffer is RX_BUFSIZE (80) characters long, which
* includes the terminating \n (but no terminating \0). If the buffer
* is full (i. e., at RX_BUFSIZE-1 characters in order to keep space for
* the trailing \n), any further input attempts will send a \a to
* uart_putchar() (BEL character), although line editing is still
* allowed.
*
* Input errors while talking to the UART will cause an immediate
* return of -1 (error indication). Notably, this will be caused by a
* framing error (e. g. serial line "break" condition), by an input
* overrun, and by a parity error (if parity was enabled and automatic
* parity recognition is supported by hardware).
*
* Successive calls to uart_getchar() will be satisfied from the
* internal buffer until that buffer is emptied again.
*/
int
uart_getchar(FILE *stream)
{
uint8_t c;
char *cp, *cp2;
static char b[RX_BUFSIZE];
static char *rxp;
if (rxp == 0)
for (cp = b;;)
{
loop_until_bit_is_set(UCSRA, RXC);
if (UCSRA & _BV(FE))
return _FDEV_EOF;
if (UCSRA & _BV(DOR))
return _FDEV_ERR;
c = UDR;
/* behaviour similar to Unix stty ICRNL */
if (c == '\r')
c = '\n';
if (c == '\n')
{
*cp = c;
uart_putchar(c, stream);
rxp = b;
break;
}
else if (c == '\t')
c = ' ';
if ((c >= (uint8_t)' ' && c <= (uint8_t)'\x7e') ||
c >= (uint8_t)'\xa0')
{
if (cp == b + RX_BUFSIZE - 1)
uart_putchar('\a', stream);
else
{
*cp++ = c;
uart_putchar(c, stream);
}
continue;
}
switch (c)
{
case 'c' & 0x1f:
return -1;
case '\b':
case '\x7f':
if (cp > b)
{
uart_putchar('\b', stream);
uart_putchar(' ', stream);
uart_putchar('\b', stream);
cp--;
}
break;
case 'r' & 0x1f:
uart_putchar('\r', stream);
for (cp2 = b; cp2 < cp; cp2++)
uart_putchar(*cp2, stream);
break;
case 'u' & 0x1f:
while (cp > b)
{
uart_putchar('\b', stream);
uart_putchar(' ', stream);
uart_putchar('\b', stream);
cp--;
}
break;
case 'w' & 0x1f:
while (cp > b && cp[-1] != ' ')
{
uart_putchar('\b', stream);
uart_putchar(' ', stream);
uart_putchar('\b', stream);
cp--;
}
break;
}
}
c = *rxp++;
if (c == '\n')
rxp = 0;
return c;
}
char
uart_getc()
{
char ch;
ch = 0;
if (UCSRA & 0x80) //RXC
ch = UDR;
return ch;
}
Kod: Markera allt
//uart.h
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
* ----------------------------------------------------------------------------
*
* Stdio demo, UART declarations
*
* $Id: uart.h,v 1.1 2005/12/28 21:38:59 joerg_wunsch Exp $
*/
/*
* Perform UART startup initialization.
*/
void uart_init(void);
/*
* Send one character to the UART.
*/
int uart_putchar(char c, FILE *stream);
//get one char from uart. Return 0 if no char.
char uart_getc();
/*
* Size of internal line buffer used by uart_getchar().
*/
#define RX_BUFSIZE 80
/*
* Receive one character from the UART. The actual reception is
* line-buffered, and one character is returned from the buffer at
* each invokation.
*/
int uart_getchar(FILE *stream);
Kod: Markera allt
//defines.c
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Joerg Wunsch
* ----------------------------------------------------------------------------
*
* General stdiodemo defines
*
* $Id: defines.h,v 1.2.2.1 2009/06/25 20:21:15 joerg_wunsch Exp $
*/
#define UBRRL UBRR0L
#define UCSRB UCSR0B
#define UCSRA UCSR0A
#define RXC RXC0
#define FE FE0
#define DOR DOR0
#define UDR UDR0
#define TXEN TXEN0
#define RXEN RXEN0
#define UDRE UDRE0
/* CPU frequency */
//#define F_CPU 1000000UL
#define F_CPU 16000000UL
/* UART baud rate */
#define UART_BAUD 9600
/* HD44780 LCD port connections */
#define HD44780_RS A, 6
#define HD44780_RW A, 4
#define HD44780_E A, 5
/* The data bits have to be in ascending order. */
#define HD44780_D4 A, 0
/* Whether to read the busy flag, or fall back to
worst-time delays. */
#define USE_BUSY_BIT 1