<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Project Notes &#187; OpenWrt Midge</title>
	<atom:link href="http://projectnotes.co.uk/category/openwrt-midge/feed/" rel="self" type="application/rss+xml" />
	<link>http://projectnotes.co.uk</link>
	<description>Random Computer, Internet and Electronics Projects</description>
	<lastBuildDate>Fri, 06 Jan 2012 13:43:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Blassic for Squidge</title>
		<link>http://projectnotes.co.uk/2008/10/blassic-for-squidge/</link>
		<comments>http://projectnotes.co.uk/2008/10/blassic-for-squidge/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 02:51:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blassic]]></category>
		<category><![CDATA[OpenWrt Midge]]></category>

		<guid isPermaLink="false">http://www.projectnotes.co.uk/?p=186</guid>
		<description><![CDATA[Following the conversations here, there is a test version of blassic to download.]]></description>
			<content:encoded><![CDATA[<p>Following the conversations <a href="http://www.projectnotes.co.uk/2008/10/io-bus-rewire-power-problems-resolved/#comment-11">here</a>, there is a test version of blassic to download.</p>
]]></content:encoded>
			<wfw:commentRss>http://projectnotes.co.uk/2008/10/blassic-for-squidge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Router I/O Bus Cable Problem</title>
		<link>http://projectnotes.co.uk/2008/09/router-io-bus-cable-problem/</link>
		<comments>http://projectnotes.co.uk/2008/09/router-io-bus-cable-problem/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 00:29:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[I/O Bus]]></category>
		<category><![CDATA[OpenWrt Midge]]></category>

		<guid isPermaLink="false">http://www.projectnotes.co.uk/?p=172</guid>
		<description><![CDATA[I am going to have to re-wire the router I/O Bus connection.  I opened the router case to investigate giving the I/O Bus it&#8217;s own 5v line &#8211; the little 78L05 regulator is really only capable of supplying 1 usb &#8230; <a href="http://projectnotes.co.uk/2008/09/router-io-bus-cable-problem/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am going to have to re-wire the router <strong>I/O Bus</strong> connection.  I opened the router case to investigate giving the I/O Bus it&#8217;s own <strong>5v</strong> line &#8211; the little <strong>78L05</strong> regulator is really only capable of supplying 1 usb device.  I was running into power troubles hooking too many things to the I/O bus.<span id="more-148"></span></p>
<p>When I tried to open the case, I found that the wires to the <strong>Scart</strong> Plug had melted themselves into the plastic base of the router!</p>
<div class="wp-caption alignnone" style="width: 350px"><img title="Router Case After the Cables Moulded Themselves to it." src="/images/Router-Base-Cable-Problem.jpg" alt="Router Case After the Cables Moulded Themselves to it." width="340" height="255" /><p class="wp-caption-text">Router Case After the Wires &#39;Moulded&#39; Themselves to it.</p></div>
<p>I thought &#8216;perhaps I had drawn too much power through the wires&#8217;, but the marks at the top of the picture are from the wires to the <strong>LED</strong>s.</p>
<p>I guess the problem is a result of a chemical reaction between the soft plastic of the base and the rubbery style insulation used on the black wires from the &#8216;cheap&#8217; <strong>scart splitter</strong>.</p>
<p>I notice that the scart to scart leads with coloured wires inside seem to be made with a different insulating material.  I&#8217;ll have to re-wire, (using one of these) as when I pulled the wires from the base, several of them left a good portion of insulation behind.</p>
]]></content:encoded>
			<wfw:commentRss>http://projectnotes.co.uk/2008/09/router-io-bus-cable-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blassic I2C Mains Remote Control</title>
		<link>http://projectnotes.co.uk/2008/09/blassic-i2c-mains-remote-control/</link>
		<comments>http://projectnotes.co.uk/2008/09/blassic-i2c-mains-remote-control/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 21:50:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blassic]]></category>
		<category><![CDATA[I/O Bus]]></category>
		<category><![CDATA[I2C]]></category>
		<category><![CDATA[OpenWrt Midge]]></category>
		<category><![CDATA[16F876A]]></category>
		<category><![CDATA[Mains Control]]></category>
		<category><![CDATA[Midge]]></category>

		<guid isPermaLink="false">http://www.projectnotes.co.uk/?p=159</guid>
		<description><![CDATA[Using the Remote Control Unit with the Pic I2C Slave connected to the Midge Router, it is possible to use Blassic to control regular mains devices via the the network.  Here is a sample. The following program requires an update &#8230; <a href="http://projectnotes.co.uk/2008/09/blassic-i2c-mains-remote-control/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using the <strong>Remote Control Unit</strong> with the <strong>Pic I2C</strong> <strong>Slave</strong> connected to the <strong>Midge</strong> <strong>Router</strong>, it is possible to use Blassic to control regular mains devices via the the network.  Here is a sample.<span id="more-139"></span></p>
<p>The following program requires an update to the PIC I2C Slave software to set <strong>PORT B</strong> to output and the Remote Control On/Off lines connected to PORTB 0 and 1.  A 0v Line is also required between the two.  I continue to run the <strong>Mains Remote Control</strong> unit with its own 12v Battery although, the 12v supply to the router could also be used.</p>
<p>The following Blassic (Basic) program sets up the Router <strong>I2C</strong> software to talk to the <strong>PIC</strong> and then inputs &#8220;On or Off&#8221; from the console.  If the Response is On, PORT B0 is set high for a few seconds.  If it is &#8216;Off&#8217;, PORT B1 is used.</p>
<p>Here is the Program Listing</p>
<pre>     10 REM Remote.bas
     11 REM Test The Mains Remote Control Via I2C
     12 REM Input On or Off then Switch the Plug On or Off
     14 REM Needs Update to PIC I2C software to Set Port B as Output
     20 REM
     30 REM I2C Control
     40 I2CAddress=34
     50 I2CData=35
     60 PIC16F876=46 : REM Address of Our Chip
     70 REM Commands
     75 PortB=1
     80 AnalogRead = 4
     90 PortA1Invert = 5 : REM Invert A1
    100 REM Begin
    105 INPUT "On or Off ",a$
    106 IF a$ = "On" THEN OnOff = 1
    107 IF a$ = "Off" THEN OnOff = 2
    110 POKE I2CAddress,PIC16F876 : REM Address the chip
    200 POKE I2CData,PortB : REM we are sending port be some data
    210 POKE I2CData,0 : REM ensure PortB All off
    220 POKE I2CData,PortB
    225 POKE I2CData,OnOff : REM Bit 0 = A1On, Bit 1 = A1Off
    230 GOSUB 800 : REM Delay long enough for the Remote Xmit
    240 POKE I2CData,PortB
    250 POKE I2CData,0 : REM and Stop Pressing Remote Buttons
    300 END
    800 FOR x=0 TO 4000: NEXT : RETURN
Ok</pre>
<p>Update:<br />
I was setting PORT B to 03 to turn off the power switch, ( B0 and B1 both HIGH) in error, the above code now only sets PORT B1 HIGH.</p>
<p>I also was getting random result trying to use a Blassic program to control the PIC 16F876a/Mains Remote from inside a shell script.  That turned out to be a power problem, I&#8217;m only using a low power regulator for the 5v rail.  This supplies both the USB Memory Stick, an LCD Display and the PIC Processor.  When the USB Memory Stick is accessed, the power dips enough to reset the PIC Processor.</p>
<p>As the LCD Display was not needed for the Power Remote Control, I simply unplugged the display from the bus and the reduced power load allowed the rest of the systems to function.</p>
<p>I will now add a second 78L05 to the router and use that to power the bus.</p>
]]></content:encoded>
			<wfw:commentRss>http://projectnotes.co.uk/2008/09/blassic-i2c-mains-remote-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PWM function in 16F876 I/O Processor</title>
		<link>http://projectnotes.co.uk/2008/08/pwm-function-in-16f876-io-processor/</link>
		<comments>http://projectnotes.co.uk/2008/08/pwm-function-in-16f876-io-processor/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 00:25:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blassic]]></category>
		<category><![CDATA[I/O Bus]]></category>
		<category><![CDATA[I2C]]></category>
		<category><![CDATA[OpenWrt Midge]]></category>
		<category><![CDATA[16F876A]]></category>
		<category><![CDATA[PWM]]></category>

		<guid isPermaLink="false">http://www.projectnotes.co.uk/?p=116</guid>
		<description><![CDATA[I have added a basic PWM service to the PIC 16F876 I2C Slave I/O Processor.  Here is the updated JAL Source and a Blassic program for the Router.  It reads the Analog input, and prints to the console or sounds &#8230; <a href="http://projectnotes.co.uk/2008/08/pwm-function-in-16f876-io-processor/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have added a basic <strong>PWM</strong> service to the <strong>PIC 16F876</strong> <strong>I2C</strong> Slave I/O Processor.  Here is the updated <strong>JAL</strong> Source and a <strong>Blassic</strong> program for the Router.  It reads the Analog input, and prints to the console or sounds a Beep using the <strong>PWM</strong> output.<span id="more-100"></span></p>
<h2>Updated JAL Source for the 16F876 I/O Processor</h2>
<pre>-- Sebastien Lelong Copyright (c) 2008, http://sirloon.net
--
-- This file is part of the Sirbot Project (http://sirbot.org)
-- Released under the GPL license
--

-- !! changes by Phill, ProjectNotes.co.uk for
-- use with the 16F876a as an I/O extender for the Midge/OpenWrt
-- &amp; Sunspot software driven routers.

-- 29/08/08 Added basic PWM support and I/O Command List
-- At Reset, PWM is set to 50% (2.5v)

-- I/O Commands
-- 01 - Write Next byte to Port B
-- 02 - Write Next Byte to H/W Serial Port
-- 03 - Next Read Byte is Latest Serial Port Rx Data OR ZERO
-- 04 - Next Read Byte is Analog in From Pin A0
-- 05 - Toggle Output Pin A1 (status led?)
-- 06 - Write Next Byte to Jal PWM  Duty Cycle

-- Once a read data command has been sent, it will star in effect until
-- another command has been sent.
-- After a Write data or immediate command (05) is complete, the command
-- byte is set to zero (ready for another command)

include 16F876a_bert

--include sb_config
--include sb_protocol
--include sb_mainboard

-- !! 16F876a port C3&amp;4 are the I2C i/o pins
-- AppNote says must be configured as input first
--pin_b4_direction = input
--pin_b1_direction = input
pin_c6_direction = output -- tx
pin_c7_direction = input  -- rx
pin_c3_direction = input
pin_c4_direction = input

-- For testing purpose (checking if slave is responding to START/STOP signals)
-- you may want to activate 7bits address with interrupts (see spec)
;;SSPCON = 0b_0011_1110	-- slave 7bit address, start/stop interrupt
SSPCON = 0b_0011_0110	-- slave 7bit address

-- I2C slave hardware
-- Careful: we're in 7bits i2c address, *but* PIC
-- wants an address coded on 8bits, that is, with read/write bit
-- In master, slave address is:
-- 		0x2E &lt;=&gt; 0b_0010_1110
-- So, in slave, by left-shifting once, we have:
--		0x5C &lt;=&gt; 0b_0101_0110
SSPADD = 0x5C

-- init SSPSTAT
BF = false
WCOL = false
SSPOV = false
SSPIF = false
-- enable interrupts
SSPIE = true
GIE = true
PEIE = true

-- !! no ready/busy leds, we want port B all OUT
-- "Ready !" LED
-- var bit ready_led_direction is pin_b0_direction
-- var bit ready_led is pin_b0
-- ready_led_direction = output
-- Error LED
-- var bit error_led_direction is pin_b3_direction
-- var bit error_led is pin_b3
-- error_led_direction = output

var byte tmpstat
var byte tmpbuf
var byte data

-- !! add a few temp registers of our own
var byte serialtemp
var byte command
var bit a1f
command = 00
a1f = off
-- !! set up our a1 toggle bit
pin_a1_direction = output
pin_a1 = a1f
-- !! set up our adc in pin
pin_a0_direction = input

-- !!

-- test to set SSPBUF to see if it's changed while receiving
-- the first byte address
SSPBUF = "A"

function read_i2c() return byte is
	tmpbuf = SSPBUF
	return tmpbuf
end function

procedure write_i2c(byte in what) is
	-- wait 'til buffer is empty
	while BF loop end loop
	var bit dosend = true
	while dosend
	loop
		WCOL = false
		-- try to write into buffer, checking collision
		SSPBUF = what
		if ! WCOL
		then
			-- ok, done
			dosend = false
		end if
		-- else continue trying
	end loop
    CKP = 1
end procedure

procedure proceed_state_1() is
	-- state 1:write operation, last byte is address, buffer full
	-- byte is an address, it we get here, we just know master
	-- wants to talk to us...
	-- and we also know address is recognized (BF is set, see spec)
	-- anyway, we must read buffer to reset BF bit
	read_i2c()
end procedure

procedure proceed_state_2() is
	-- state 2: write operation, last byte is data, buffer full
	-- got data, need to echo char + 1
	data = read_i2c()
	-- ultimate data processing... <img src='http://projectnotes.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
  -- !! here do something useful
  if command == 01 then
  portb = data
  data = 0
  end if
  if command == 02 then
  serial_hw_write(data)
  data = 0
  end if
  if command == 06 then

  PWM_set_dutycycle (data,data)
  data = 0
  end if
  command = data -- Not in a command, this must be a command.
  -- if we don't handle it here, it may be a read data command
  if command == 05 then
  a1f = ! a1f
  pin_a1 = a1f
  command = 0 -- done with this command
  end if

end procedure

procedure proceed_state_3() is
	-- state 3: read operation, last byte is address, buffer empty
	-- master wants to get a value from us

  --!! decide what data to return
  if command == 03 then
  data = serialtemp -- last serial rx char
  serialtemp = 0 -- clear it
  end if
	if command == 04 then
	data = ADC_read_low_res(0)
	end if
	write_i2c(data)
end procedure

procedure proceed_state_4() is
	-- state 4: read operation, last byte is data, buffer empty
	-- master still wants to get a value from us
	write_i2c(data)
	-- note: this shouldn't occur
end procedure

procedure proceed_state_5() is
	-- state 5: nack
	-- master doesn't want to talk with us anymore
	-- reset slave logic
	-- AN734 does not talk about setting CKP, whereas spec says
	-- it must be set. Some people say it can be error prone.
    CKP = 1
	data = 0
end procedure

procedure proceed_error() is
	-- something went wrong, that is, XOR operations did not match
	-- SSPSTAT bits
	-- Just log current status
	serial_hw_write("E")
	serial_hw_write(SSPSTAT)
end procedure

procedure ssp_handler() is
	pragma interrupt
	if SSPIF
	then
		SSPIF = false
		tmpstat = SSPSTAT
		-- mask out unimportant bit
		tmpstat = tmpstat &amp; 0b_0010_1101
		-- check state 1: write operation, last byte is address, buffer full
		if (tmpstat ^ 0b_0000_1001) == false
		then
			proceed_state_1()
		-- check state 2: write operation, last byte is data, buffer full
		elsif (tmpstat ^ 0b_0010_1001) == false
		then
			proceed_state_2()
		-- check state 3: read operation, last byte is address, buffer empty
		elsif (tmpstat ^ 0b_0000_1100) == false
		then
			proceed_state_3()
		-- check state 4: read operation, last byte is data, buffer empty
		elsif (tmpstat ^ 0b_00101100) == false
		then
			proceed_state_4()
		-- check state 5: nack
		elsif (tmpstat ^ 0b_0010_1000) == false
		then
			proceed_state_5()
		-- check only got a start signal (when using interrupts)
		else
			proceed_error()
		end if
	else
		-- another interrupt. Weird...
--		ready_led = low
--		delay_10ms(100)
--		ready_led = high
		serial_hw_write("*")
	end if
end procedure
-- don't need status leds
--ready_led = low

--error_led = high
--delay_10ms(30)
--error_led = low
--delay_10ms(30)
--error_led = high
--delay_10ms(30)
--error_led = low
--delay_10ms(30)
--error_led = high
--delay_10ms(30)
--error_led = low

--ready_led = high

-- 29/08/08 add PWM support
pin_c2_direction = output
PWM_init_frequency (true,true)
PWM_set_dutycycle(128,128)

forever loop
	-- just loop until interrupt is raised
	-- !! poll the serial port

	if RCIF then
    serial_hw_read(serialtemp)
    serial_hw_write(serialtemp) -- echo to confirm hardware is working!
 end if

end loop</pre>
<p>Next, the Blassic source</p>
<h2><!--more-->AnalogLightWarn.bas</h2>
<p>The following <strong>Blassic</strong> program uses the <strong>PIC 16F876a</strong> <strong>I2C</strong> I/O processor to monitor a solar panel (1.5v max!) If the light reading changes by less than 2 up or down, no action is taken.</p>
<p>If the light increases by more than 2, a message is sent to the console.</p>
<p>If the light decreases by more than 2, a beep is sounded via a small speaker connected to the PWM output pin (Port C,2).</p>
<p>As the speaker is only 8 ohms, a 47 ohm resistor and 1uf capacitor are inline to limit the current through the speaker coil.</p>
<p>The Tone of the beep is quite low, this is because of the speed of the basic interpreter AND the time it takes to send 4 bytes of instruction via the I2C Interface.</p>
<p>Later I will look at using an alternative method of sending data to the 16F876 via two other led lines, simply clocking out the required data.</p>
<pre>     10 REM Read the Analog Input A0
     15 REM if the level is a lot different from last time, say helo
     20 REM
     30 REM I2C Control
     40 I2CAddress=34
     50 I2CData=35
     60 PIC16F876=46 : REM Address of Our Chip
     70 REM Commands
     80 AnalogRead = 4
     90 PortA1Invert = 5 : REM Invert A1
    100 REM Begin
    105 last=0
    110 POKE I2CAddress,PIC16F876 : REM Address the chip
    120 POKE I2CData,AnalogRead
    130 a = PEEK(I2CData)
    135 REM PRINT a
    140 POKE I2CData,PortA1Invert
    150 IF ((a&gt;last) AND (a-last &gt; 2)) THEN GOSUB 300
    160 IF ((a&lt;last) AND (  last-a &gt; 2)) THEN  GOSUB 400
    165 last = a : REM remember for next time
    170 REM pause
    180 FOR x=0 TO 1000: NEXT
    190 GOTO 120
    300 REM lighter
    310 PRINT "Lighter"
    320 RETURN
    400 REM Darker
    410 FOR N=1 TO 30
    420 POKE I2CData,6 : POKE I2CData,255 : REM PWM=0v
    430 POKE I2CData,6 : POKE I2CData,0 : REM PWM = 5v
    450 NEXT N
    460 RETURN
Ok</pre>
]]></content:encoded>
			<wfw:commentRss>http://projectnotes.co.uk/2008/08/pwm-function-in-16f876-io-processor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blassic PIC I2C I/O with Peek &amp; Poke</title>
		<link>http://projectnotes.co.uk/2008/08/blassic-pic-i2c-io-with-peek-poke/</link>
		<comments>http://projectnotes.co.uk/2008/08/blassic-pic-i2c-io-with-peek-poke/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 02:19:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blassic]]></category>
		<category><![CDATA[I2C]]></category>
		<category><![CDATA[OpenWrt Midge]]></category>
		<category><![CDATA[16F876A]]></category>
		<category><![CDATA[Midge]]></category>

		<guid isPermaLink="false">http://www.projectnotes.co.uk/?p=104</guid>
		<description><![CDATA[Here is a little (extended)Blassic program to read the PIC 16F876A I2C Slave. It first sets up the I2C Address. Then, Writes commands to read the PIC Serial Port, Toggling Port A,1 every New Line. The program exits if a &#8230; <a href="http://projectnotes.co.uk/2008/08/blassic-pic-i2c-io-with-peek-poke/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here is a little (extended)Blassic program to read the <strong>PIC</strong> <strong>16F876A</strong> <strong>I2C</strong> Slave.<span id="more-88"></span></p>
<p>It first sets up the <strong>I2C Address</strong>.</p>
<p>Then, Writes commands to read the <strong>PIC Serial Port</strong>, Toggling Port A,1 every New Line.</p>
<p>The program exits if a &#8220;!&#8221; is received.</p>
<pre>midge# more PeekPokeTest.bas
10 POKE 34,46 :  REM our chip at 2e
20 POKE 35,3 :  REM select serial port
30 a = PEEK(35) REM Get a serial Char (0 if none ready)
40 IF a = 0 THEN GOTO 30
50 PRINT CHR$(a);
55 IF a &lt;&gt; 13 THEN GOTO 60
56 POKE 35,5 : REM toggle port A1
57 POKE 35,3 : REM back to serial port
60 IF a &lt;&gt; 33 THEN 30
midge#</pre>
]]></content:encoded>
			<wfw:commentRss>http://projectnotes.co.uk/2008/08/blassic-pic-i2c-io-with-peek-poke/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Router I2C Interface</title>
		<link>http://projectnotes.co.uk/2008/08/router-i2c-interface/</link>
		<comments>http://projectnotes.co.uk/2008/08/router-i2c-interface/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 19:02:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[I/O Bus]]></category>
		<category><![CDATA[I2C]]></category>
		<category><![CDATA[OpenWrt Midge]]></category>
		<category><![CDATA[Midge]]></category>
		<category><![CDATA[PIC]]></category>

		<guid isPermaLink="false">http://www.projectnotes.co.uk/?p=50</guid>
		<description><![CDATA[These are the I2C Bus Hardware and Software settings I am using with the on OpenWrt Midge router to talk to a PIC 16F876 I2C Slave. I2C Hardware Here is the level shifter I&#8217;m using for the Router (3v) I2C &#8230; <a href="http://projectnotes.co.uk/2008/08/router-i2c-interface/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>These are the <strong>I2C</strong> Bus Hardware and Software settings I am using with the on <strong>OpenWrt</strong> <strong>Midge</strong> router to talk to a PIC <strong>16F876</strong> I2C Slave.<span id="more-43"></span></p>
<h2>I2C Hardware</h2>
<p>Here is the level shifter I&#8217;m using for the Router (3v) I2C interface (5v on Pic and other chips I have)</p>
<pre>                 5v
                |
                |
                R
               4k7
                R
                |
SCL ---+--R220--+-----&gt; 5v SCL
       |
     =====  Use the Same
      ZD\   For the Data
     /3.3\  Line
       |
       |
0v-----+---------------</pre>
<p>The above has so far worked happily with an old philips 2048bit (256 bytes!) eeprom.</p>
<p>Pin Header (for breadboard)</p>
<p>1: 0v</p>
<p>2: 3v</p>
<p>3: 5v</p>
<p>4: KEY NC</p>
<p>5: TX (I/O Bus -&gt; project)</p>
<p>6: RX (project &lt;- I/O Bus)</p>
<p>7: LED3 GPIO8 I2C SDA</p>
<p>8: LED5 GPIO11 I2C SCL</p>
<h2>I2C Software Settings</h2>
<p>In the sunspot.co.uk Midge rom, the default <strong>I2C</strong> port uses different gpio lines.  To use gpio 8 and 11, the file &#8220;/etc/init.d/S99start_i2c&#8221; file needs changing:-</p>
<p>The line containing &#8220;insmod i2c-adm5128&#8243; needs to read &#8220;insmod i2c-adm5120 scl=11 sda=8&#8243;</p>
]]></content:encoded>
			<wfw:commentRss>http://projectnotes.co.uk/2008/08/router-i2c-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I/O Bus Connections</title>
		<link>http://projectnotes.co.uk/2008/08/io-bus-connections/</link>
		<comments>http://projectnotes.co.uk/2008/08/io-bus-connections/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 00:00:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[I/O Bus]]></category>
		<category><![CDATA[OpenWrt Midge]]></category>
		<category><![CDATA[I2C]]></category>

		<guid isPermaLink="false">http://www.projectnotes.co.uk/?p=27</guid>
		<description><![CDATA[These are the Connections I am using on the I/O Bus. The Scart Connector Pins +==============================+ &#124; 1 3 5 7 9 11 13 15 17 19&#124;(21) - - shield &#124; \ &#124; 2 4 6 8 10 12 14 &#8230; <a href="http://projectnotes.co.uk/2008/08/io-bus-connections/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>These are the Connections I am using on the I/O Bus.<span id="more-22"></span></p>
<p>The Scart Connector Pins</p>
<pre>+==============================+
| 1  3  5  7  9  11 13 15 17 19|(21) - - shield
|                               \
|  2  4  6  8  10 12 14 16 18 20 |
+================================+</pre>
<p>Bus Connections &amp; LED I/O Line Use.</p>
<table border="0">
<tbody>
<tr>
<td width="50%">1 LED3 I2C SDA</p>
<p>3 LED5 I2C SCL</p>
<p>5 LED7</p>
<p>7 LED9</p>
<p>9 LED11 LCD RS</p>
<p>11 0v</p>
<p>13 0v</p>
<p>15 +3v</p>
<p>17 +5v</p>
<p>19 Serial TX</td>
<td width="50%">2 LED 4 LCD D4</p>
<p>4 LED6 LCD D5</p>
<p>6 LED8 LCD D6</p>
<p>8 LED10 LCD D7</p>
<p>10 LED12 LCD E</p>
<p>12 0v</p>
<p>14 +3v</p>
<p>16 +5v</p>
<p>18 Reset Input</p>
<p>20 Serial RX</td>
</tr>
</tbody>
</table>
<p>I added extra power lines as the wire used is quite fine.  The extra power and 0v lines are connected at the router, they are not linked on the Bus I/O board to avoid any ground loop.</p>
]]></content:encoded>
			<wfw:commentRss>http://projectnotes.co.uk/2008/08/io-bus-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a Serial Port</title>
		<link>http://projectnotes.co.uk/2008/08/adding-a-serial-port/</link>
		<comments>http://projectnotes.co.uk/2008/08/adding-a-serial-port/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 23:46:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenWrt Midge]]></category>
		<category><![CDATA[I/O Bus]]></category>
		<category><![CDATA[Midge]]></category>
		<category><![CDATA[PIC]]></category>

		<guid isPermaLink="false">http://www.projectnotes.co.uk/?p=24</guid>
		<description><![CDATA[Fitting a serial converter and lead insider the I/O Bus box gives us back a socket for other projects and gets the serial converter out of harms way.  Cutting a couple of I/O Bus tracks opens up even more options. &#8230; <a href="http://projectnotes.co.uk/2008/08/adding-a-serial-port/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Fitting a serial converter and lead insider the I/O Bus box gives us back a socket for other projects and gets the serial converter out of harms way.  Cutting a couple of I/O Bus tracks opens up even more options.<span id="more-20"></span></p>
<p>I have been using the 5 port &#8216;scart socket&#8217; I/O Bus simply as a passive backplane.  All of the lines are bussed together and using it simply involves hooking up the correct pins of a scart type plug to the corresponding pins on a circuit.</p>
<p>The <a title="The 5 port I/O Bus made from a scart splitter" href="http://www.projectnotes.co.uk/cheap-io-bus/">I/O bus</a> started life as a cheap breakout box for the Sweex/Edimax Router so that I could hook up different circuits to it without risking physical damage to the router itself &#8211; at least I won&#8217;t be able to break off a component whilst connecting a new circuit.</p>
<p>The Bus simply carries the router led, power (3v and 5v) and serial lines. I have been using a transistor based level converter to connect the router to a PC for uploading new ROM images.</p>
<p>Now that I&#8217;m going to add a PIC Processor and try a bit of communication between the PIC and the Router, it occured to me that it would be useful if I cut the serial lines somewhere on the bus so that I could hook up more than one serial device &amp; converter.</p>
<p>However, there is just room for my level converter or one based on a MAX232 IC (a better idea if you have one handy) where the original scart lead exited the case.</p>
<p>I added the circuit, connecting it to the nearest socket and cut the traces between the serial pins and the rest of the I/O Bus.</p>
<p>Now, if I need to boot the router and upload a new ROM Image or work with the serial port, I plug the router into the first socket.  If I move the router to another socket, I can plug a PIC or whatever into the first socket and upload software to that.</p>
]]></content:encoded>
			<wfw:commentRss>http://projectnotes.co.uk/2008/08/adding-a-serial-port/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

