I’ve been swamped the last couple of weeks with a Coursera course on Compilers and a new grandson. Hoping to get some more work done on Olduino in May.
I’ve had another yet another go at the SPI clock. I had been using SBI/CBI to set the clock bits which is much faster than digitalWrite() but was still giving me a frequency around 1 mhz. I decided to dedicate port C to the clock & not-clock lines so I could trigger them with PORTC=xx which should translate to a single instruction. I actually had to add a no-op between the assignments to keep the frequency around 2 MHZ. The 4021 shift register wants a pulse of at least 180 uS and I was below that without the no-op. I may look at a faster shift register for a later version but i think this will make enough of a difference for now. In the picture below you see the new 2mhz clock waveform and the old 1mhz. the code below is the output of objdump showing the c source and generated assembly.
PORTC=0x02;//clock up, notclock down 158: 82 e0 ldi r24, 0x02 ; 2 15a: 88 b9 out 0x08, r24 ; 8 PORTC=0x01;//clock down, notclock up 15c: 91 e0 ldi r25, 0x01 ; 1 15e: 98 b9 out 0x08, r25 ; 8 asm("nop\n"); 160: 00 00 nop PORTC=0x02;//clock up, notclock down 162: 88 b9 out 0x08, r24 ; 8 asm("nop\n"); 164: 00 00 nop
Over the two days it was up it served almost 500 pages to 25 or so clients. I’m not exactly sure how many because the IP table wrapped around(by design). It was really slow rendering the contact list and i found out why once it was down. In the background it was doing a lot of debug printing including all the ips each time it ran the table. my itoa() is stupid slow and that alone was adding a couple of seconds.
The final client table is shown below:
Client Table 188.8.131.52 Australia 184.108.40.206 Ireland 220.127.116.11 Czech 18.104.22.168 Sbirdasn 22.214.171.124 Craig 126.96.36.199 Scott 188.8.131.52 The 184.108.40.206 mlventura 220.127.116.11 Dr. 18.104.22.168 AndrewWassonBCC 22.214.171.124 Mike_USA 126.96.36.199 USA 192.168.0.3 BillAgain 188.8.131.52 Bill 184.108.40.206 Bill 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 & 220.127.116.11 & 18.104.22.168 & 22.214.171.124 & 126.96.36.199 Kevin 188.8.131.52 Kevin 184.108.40.206 Dave 220.127.116.11 18.104.22.168 WeAreANONYMOUS 22.214.171.124 Australia 126.96.36.199 Australia
This is what happens if you don’t scrub text fields, browsers replace special characters with codes.
The olduino server is back online at http://188.8.131.52:1802
The obvious change is that instead of reporting the LED status with text it shows an animated picture of the board with the LED either on or off. All I had to do was change the text I sent out from “The LED is ON” to a HTML img tag and your browser does the hard part of fetching the picture and displaying it.
Under the covers the big change is that it pays attention to the IP of an incoming request. If it hasn’t seen a particular IP before it invites you to tell it your name or where you are. It displays a rolling list of the last 32 contacts. I originally thought I would have some kind of multi-player game but I couldn’t think of one.
I’m back with the multi-user web server. I made a table of IP addresses and names that’s managed by the server and displayed with a button on the form. My table management is very basic: it starts with a next-slot index pointing to the beginning of the table and puts a new user into that slot, incrementing the variable. If it gets to the end of the table it wraps around re-using the slot. I tried out the logic with only three slots and i was able to drive a wrap-around by using the laptop, a tablet and my phone – the phone could present as two different ips because it has cellular access.
The simplistic table structure means you have to search the whole table to find an entry. I was worried that would be slow but what’s strikingly slow even with just a few entries is displaying the table – each row takes 1/3 second. It turns out the time is being spend in my old friend the itoa() routine which converts integers for printing as ascii strings. I used a simplistic C routine for doing it and never optimized it. I wrote something better in assembly for longs but never did for ints. I’ll have to get on that sometime. In the mean time I’ll just change things not to display IPs as much.
I’m not real sure where this is going but I had the idea for a multi-user web server on the olduino ethernet. So far it is just triggering behaviour depending on the ip of the browser requesting the page. If it’s an unknown IP it asks for a name or country identifier. If the name or country is already known it shows the toggle led button.
The code is a mess and the overall behaviour is simplistic but if i had an idea for a simple multi-user game i have a framework to implement it.