Velleman K8056 Relay Board:
Im using a MikroC USART library for my PIC18F4550. The code is below. Ive checked the data coming from the microcontroller by using the PC terminal it is correct. With the USART function i can only send one byte at a time; i have to wait for the byte to be sent before sending the next.
There i a delay between bytes, is this a problem?
Is it ok to send bytes one at a time with the start/stop bit every time or should there be one start/stop bit for the whole command frame?
Alink to a video of the setup: http://www.youtube.com/watch?v=tMcISl9hJCE
Thanks
[code]char UART_temp;
unsigned char data_send [50];
int num = 0;
int count = 0;
void ledblink()
{
PORTD = 0x00;
Delay_ms(100);
PORTD = 0xFF;
Delay_ms(100);
PORTD = 0x00;
Delay_ms(100);
PORTD = 0xFF;
}
void main()
{
ADCON1 = 0x0F;
TRISD = 0x00;
PORTD = 0xFF; //LED INDICATOR ON portD
UART1_Init(2400); // Initialize UART module
Delay_ms(1000); // Wait for UART module to stabilize
data_send[0] = 0x0D;
data_send[1] = 0x01;
data_send[2] = 0x53;
data_send[3] = 0x31;
data_send[4] = 0x6E;
ledblink();
while (1)
{
if((UART1_Tx_Idle() == 1) && (num<5))
{
UART1_Write(data_send[num]);
num = num + 1;
}
}
}
[/code]