Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Velleman K8056 Relay Board communication problem

Status
Not open for further replies.

brucelee2

Member level 2
Joined
Aug 22, 2009
Messages
49
Helped
6
Reputation
12
Reaction score
3
Trophy points
1,288
Location
on a PCB
Activity points
1,638
Im trying to control my Velleman K8056 Relay Board using a microcontroller. The board works fine when connected to the PC using the Velleman program.
Im using a MAX232 level converter between the MCU and PC/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.

Im sending:
0D 01 53 31 6E (which turns on relay one of card adressed one). Sending this by the PC using a terminal makes the board work, but using the MCU i cant get it to work.

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?


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;
                  }

            }
 }

Added after 2 hours 54 minutes:


A video of the setup
 

Found the problem. It was a faulty MAX232 level converter. When the MAX232 was connected to the relay board then the signal output became poor, this was not the case when connected to the PC. NOw it works fine.

Thanks anyway
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top