Embedded system Fun Blog
























































Find out all the best information, libraries and circuit about the latest Embedded systems.
Showing posts with label ip. Show all posts
Showing posts with label ip. Show all posts

Monday, 5 March 2012

3.3v to 5v converter (Episode 2/5)

Conversion between the 3.3v to 5v logic signal.

.from: http://www.edaboard.com/thread11539.html

Hot to do an 5V signal will be level-shift to 3.3V and the 3.3V signal will pass-thru directly without attentuation.

Solution 1:
My simple method is to use serial resistor divider (few kilos, ie. 10kR) and diode (Schottky diode) to +3.3V (A - resistor, K - +3.3V).

Solution 2:
look 74LVC series chips, that's also available in very small one gate package ( and it is very low cost, for example the Philips 74LVC1G125GW or Texas Instruments SN74LVC1G125DCKR chips in small 5 pim SC-70-5 packege, low unit cost

Solution 3:
Take a look at www.chipcon.com in Application Note AN021. Texas Instruments has a similar good  PDF appnote also.

Sunday, 8 January 2012

MBED: UDP Socket Example 1 (Cookbook)

.from: http://mbed.org/users/donatien/programs/UDPSocketExample/5yuvy

XxXxXxXxXxXxXxXxXxXxXxXxXxXxXx main.cpp XxXxXxXxXxXxXxXxXxXxXxXxXxXxXx

#include "mbed.h"
#include "EthernetNetIf.h"
#include "UDPSocket.h"

EthernetNetIf eth;
UDPSocket udp;

void onUDPSocketEvent(UDPSocketEvent e)
{
  switch(e)
  {
  case UDPSOCKET_READABLE: //The only event for now
    char buf[64] = {0};
    Host host;
    while( int len = udp.recvfrom( buf, 63, &host ) )
    {
      if( len <= 0 )
        break;
      printf("From %d.%d.%d.%d: %s\n", host.getIp()[0], host.getIp()[1], host.getIp()[2], host.getIp()[3], buf);
    }
    break;
  }
}

int main() {
  printf("Setting up...\n");
  EthernetErr ethErr = eth.setup();
  if(ethErr)
  {
    printf("Error %d in setup.\n", ethErr);
    return -1;
  }
  printf("Setup OK\n");
 
  Host multicast(IpAddr(239, 192, 1, 100), 50000, NULL); //Join multicast group on port 50000

  udp.setOnEvent(&onUDPSocketEvent);
 
  udp.bind(multicast);
 
  Timer tmr;
  tmr.start();
  while(true)
  {
    Net::poll();
    if(tmr.read() > 5)
    {
      tmr.reset();
      const char* str = "Hello world!";
      udp.sendto( str, strlen(str), &multicast );
      printf("%s\n", str);
    }
  }

 
}

XxXxXxXxXxXxXxXxXxXxXxXxXxXxXx EOF XxXxXxXxXxXxXxXxXxXxXxXxXxXxXx