Saturday, February 11, 2017

Stepper motor and the parallel port.


Various stepper motors, They are great for robots and other automation projects.  The same ideas can be used with micro-controllers.Here are just a few notes. Testing stepper motor wiring: http://www.piclist.com/techref/io/stepper/wiresmeterbattery.htm


The bipolar motor (4 wire):



From an old Seagate hard drive.









Unipolar motor.







CLS
VarMode = 0
VarRot = 0
VarRev = 0
VarDelay = 0
int1 = 0


Main:
CLS
OUT 888, 0
DO UNTIL INKEY$ <> ""
PRINT "Enter the number of revolutions"
INPUT VarRev
VarRev = VarRev * 50
PRINT "Enter the Mode of operation"
PRINT " 1 for single coil excitation"
PRINT " 2 for double coil excitation"
INPUT VarMode
PRINT "Enter the number of delay cycles"
INPUT VarDelay
PRINT "Enter the direction of rotation"
PRINT "5 for CW 7 for CCW"
INPUT VarRot
VarMode = VarRot + VarMode
IF VarMode = 6 THEN GOTO ScCW:
IF VarMode = 7 THEN GOTO DcCw:
IF VarMode = 8 THEN GOTO ScCcw:
IF VarMode = 9 THEN GOTO DcCcw: ELSE GOTO nd:

LOOP

ScCW:
DO
GOSUB Step1:
GOSUB Step2:
GOSUB Step3:
GOSUB Step4:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

ScCcw:
DO
GOSUB Step4:
GOSUB Step3:
GOSUB Step2:
GOSUB Step1:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

DcCw:
DO
GOSUB Step5:
GOSUB Step6:
GOSUB Step7:
GOSUB Step8:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

DcCcw:
DO
GOSUB Step8:
GOSUB Step7:
GOSUB Step6:
GOSUB Step5:
VarRev = VarRev - 1
IF VarRev = 0 THEN GOTO Main:
LOOP

Step1:
OUT 888, 0
DO
OUT 888, 1
IF int1 = VarDelay THEN RETURN
int1 = int1 + 1
LOOP


Step2:
OUT 888, 0
DO
OUT 888, 2
IF int1 = 0 THEN RETURN
int1 = int1 - 1
LOOP

Step3:
OUT 888, 0
DO
OUT 888, 4
IF int1 = VarDelay THEN RETURN
int1 = int1 + 1
LOOP

Step4:
OUT 888, 0
DO
OUT 888, 8
IF int1 = 0 THEN RETURN
int1 = int1 - 1
LOOP

Step5:
OUT 888, 0
DO
OUT 888, 3
IF int2 = VarDelay THEN RETURN
int2 = int2 + 1
LOOP

Step6:
OUT 888, 0
DO
OUT 888, 6
IF int2 = 0 THEN RETURN
int2 = int2 - 1
LOOP

Step7:
OUT 888, 0
DO
OUT 888, 12
IF int2 = VarRev THEN RETURN
int2 = int2 + 1
LOOP

Step8:
OUT 888, 0
DO
OUT 888, 9
IF int2 = 0 THEN RETURN
int2 = int2 - 1
LOOP



nd:
OUT 888, 0

Other motors:



Saturday, February 4, 2017

Just a quick tip or two with Kodi.

One of the interesting features in Kodi is setting the country and time zone: Here is a picture tour of where to go.








The other quick hint is that having a remote control might be an issue.    To set a web interface add-on as the default web UI, go to System -> Services -> Webserver and select that add-on for the Default value. Then go to the hostname (or IP address) of that HTPC+Port number. Note: Some platforms use port 80, which is the assumed port if no port is given in the address. Now you can use a touchpad with a browser or a laptop.  Setting up am entry in the local dns will make things easier. I like the fact that the cursor keys work great with the system. Personally I just use an old 600 mhz laptop to be the remote control. Allows you to use the internet if you need to or even just use an editor to take notes.


That's it for now.

Friday, December 30, 2016

Legacy computer home automation server


Using legacy systems to do home automation when an Arduino or Raspberry Pi may not be available. They can work just as well. 


Server is a Pentium III with Ubuntu and Apache2. Enabled CGI (common gateway interface). Wrote all my own scripts using html, bash, and compiled freebasic (controls the leds).    Leds are connected to the parallel port via a home made adapter cable. Most of the code and interfaces are described in previous articles.  Added the video to the home web page:


Time to control real world object such as a coffeemaker.


For more information: http://www.tldp.org/HOWTO/text/Coffee

Wednesday, December 28, 2016

Chromecast ethernet.


You can use ethernet with the Chromecast (1), you just need a usb ethernet adapter and then a otg y host adapter (system must be up to date).


Then it should be plug and play if you have the right ethernet adapter. Tried my ethernet adapter and it did not work. Went to Frys who had the right usb to ethernet adapter.



All was well till I found that the Home android app on the Nexus 7 did not seem to support ethernet. Though I did not spend anytime seeing whether it could be done. A bummer.

Monday, December 26, 2016

Five volt adapter.

If you have a bunch of old +5v powerblocks with barrel connectors, then you may think they are worthless. Not so you can now get adapters to keep using the old powerblocks with your Raspberry Pi.
With the adapter, you can still use the power block as you always have and no soldering required.

You could also adapt an old computer power supply. Dangerous!! Wrongly set up it could KILL you Do not do this without expert help. Every power supply is different so you will have to tget the pinout for your power supply to be used. Do not do anything while the splly is plugged in on or off!!!!  Suggestions: User your favorite search engine.
AT:

ATX:


Polarity matters:




Barebone arduino ethernet.

Notice: use at your own risk.


If you have an Arduino with a removable chip, then you can use that to program the chip. Otherwise there are circuits to program the standalone Arduino. See "https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard" for more details".

 


The bare Arduino setup.


You need a power source not shone. We used a 4 D size battery setup. Barebones setup before adding ethernet:



Wiring:







 Downloaded the latest Arduino and Ethercard software. Loaded both of them on the computer. Imported code for a simple web server.

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

#define STATIC 0  // set to 1 to disable DHCP (adjust myip/gwip values below)

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x28 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Service Temporarily Unavailable"
  "</title></head>"
  "<body>"
    "<h3>This service is currently unavailable</h3>"
    "<p><em>"
      "The main server is currently off-line.<br />"
      "Please try again later."
    "</em></p>"
  "</body>"
"</html>"
;

void setup(){
  Serial.begin(9600);
  Serial.println("\n[backSoon]\n");
   
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip); 
  ether.printIp("DNS: ", ether.dnsip); 
}

void loop(){
  // wait for an incoming TCP packet, but ignore its contents
  if (ether.packetLoop(ether.packetReceive())) {
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);
  }
}

Finished setup:



Thursday, December 15, 2016

Documentation is bad sometimes.




Sometimes you just want to tear your hair out when the documentation of a product is WRONG. Something I ran into recently when trying to attach an enc28j60 from Hanrun to my genuine Arduino. I have used the ethernet shield on the Arduino without a hitch. So I supposed there would be no problem again... So I thought. Followed the map for hooking the two devices together as follows:

VCC -   3.3V
GND -    GND
SCK - Pin 13
SO  - Pin 12
SI  - Pin 11
CS  - Pin  8

Downloaded the latest Arduino and Ethercard software. Loaded both of them on the computer. Imported code for a simple web server.

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

#define STATIC 0  // set to 1 to disable DHCP (adjust myip/gwip values below)

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x28 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Service Temporarily Unavailable"
  "</title></head>"
  "<body>"
    "<h3>This service is currently unavailable</h3>"
    "<p><em>"
      "The main server is currently off-line.<br />"
      "Please try again later."
    "</em></p>"
  "</body>"
"</html>"
;

void setup(){
  Serial.begin(9600);
  Serial.println("\n[backSoon]\n");
   
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip); 
  ether.printIp("DNS: ", ether.dnsip); 
}

void loop(){
  // wait for an incoming TCP packet, but ignore its contents
  if (ether.packetLoop(ether.packetReceive())) {
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);
  }
}



Then I proceeded to compile it.  Actually I had used other bits of code that would not compile until used this code. Well I proceeded to compile the code using a static ip address and all was well or so i thought. Brought up a web page and obviously it did not work. So like any good tech, you go to the web to get an answer, There were suggestion to change the mac address, and even using the +5 volt line instead of the 3.3v line. All of which did not work. Eventually I found an article that said the ethernet shield module used the #10 line on the Arduino.  The current configuration used the #8 line. What??? With nothing to lose, I used the #10 line instead of the #8 and viola everything worked with the 3.3v line being used. Whew that was a killer, Bad documentation will eat your lunch. Surprised I did not see that fix on the web, The new configuration is now:

Arduino         Module
digital 12         SO
digital 11         ST
digital 13         SCK
digital 10         CS
3.5v                  Vcc
Gnd         GND



So here are the results!



It seems to work with the Arduino mega also.