Monthly Archives: August 2013

AVR Tutorials

Wikibooks: C-Programmierung mit AVR-GCC

mikrocontroller.net: AVR-GCC-Tutorial
mikrocontroller.net: AVR-GCC-Tutorial/LCD-Ansteuerung
mikrocontroller.net: AVR-GCC-Tutorial/Analoge Ein- und Ausgabe
mikrocontroller.net: AVR-ASM-Tutorial
mikrocontroller.net: Bitmanipulation

Pin Change Interrupt (PCINT) mit dem ATMega oder Arduino
Pin-change interrupts on Arduino

Tuxgraphics: AVR C-programming tutorial

RN-Wissen: AVR
RN-Wissen: AVR-Einstieg leicht gemacht
RN-Wissen: AVR-GCC

conelek: AVR C: Softwareentwicklung mit dem AVR Studio 5

ladyada: AVR Tutorial

SiSy avr-cpp: AVR C++ Tutorial

BIND: Zone Debugging

$TTL 300
$ORIGIN ch.
zhaw                    SOA     dns1.zhaw.ch. root.srv-lab-t-668.zhaw.ch. (2013081601 1800 1800 1800 1800)
                        NS      dns1.zhaw.ch.
                        NS      dns2.zhaw.ch.

$ORIGIN zhaw.ch.
srv-lab-t-668           A       160.85.23.67

;; RECORDS: naptr
srv-lab-t-668           NAPTR   2 0 "s" "SIP+D2U" "" _sip._udp.srv-lab-t-668.zhaw.ch.
srv-lab-t-668.          NAPTR   2 0 "s" "SIP+D2T" "" _sip._tcp.srv-lab-t-668.zhaw.ch.

$ORIGIN srv-lab-t-668.zhaw.ch.

;; RECORDS: proxy
_sip._udp               SRV     10 10 5060  srv-lab-t-668.zhaw.ch.
_sip._tcp               SRV     10 10 5060  srv-lab-t-668.zhaw.ch.
_sips._tcp              SRV     10 10 5061  srv-lab-t-668.zhaw.ch.
_sip._tls               SRV     10 10 5061  srv-lab-t-668.zhaw.ch.

;; RECORDS: rr
_sip._tcp.mwi           SRV     10 10 5110  srv-lab-t-668.zhaw.ch.
_sip._tcp.vm            SRV     10 10 15060 srv-lab-t-668.zhaw.ch.
_sip._tcp.rr            SRV     10 10 5070  srv-lab-t-668.zhaw.ch.

;; RECORDS: im
;; RECORDS: a
# named-checkzone srv-lab-t-668.zhaw.ch srv-lab-t-668.zhaw.ch.zone
srv-lab-t-668.zhaw.ch.zone:6: ignoring out-of-zone data (zhaw.ch)
srv-lab-t-668.zhaw.ch.zone:15: ignoring out-of-zone data (srv-lab-t-668)
zone srv-lab-t-668.zhaw.ch/IN: has 0 SOA records
zone srv-lab-t-668.zhaw.ch/IN: has no NS records
zone srv-lab-t-668.zhaw.ch/IN: not loaded due to errors.

Problem

  • ‘zhaw.ch’ is outside the loaded zone ‘srv-lab-t-668.zhaw.ch’
  • Typo in second NAPTR record: no ‘.’!
$TTL 300

$ORIGIN zhaw.ch.
srv-lab-t-668           A       160.85.23.67
                        SOA     dns1.zhaw.ch. root.srv-lab-t-668.zhaw.ch. (2013081601 1800 1800 1800 1800)
                        NS      dns1.zhaw.ch.
                        NS      dns2.zhaw.ch.

;; RECORDS: naptr
srv-lab-t-668           NAPTR   2 0 "s" "SIP+D2U" "" _sip._udp.srv-lab-t-668.zhaw.ch.
srv-lab-t-668           NAPTR   2 0 "s" "SIP+D2T" "" _sip._tcp.srv-lab-t-668.zhaw.ch.

$ORIGIN srv-lab-t-668.zhaw.ch.

;; RECORDS: proxy
_sip._udp               SRV     10 10 5060  srv-lab-t-668.zhaw.ch.
_sip._tcp               SRV     10 10 5060  srv-lab-t-668.zhaw.ch.
_sips._tcp              SRV     10 10 5061  srv-lab-t-668.zhaw.ch.
_sip._tls               SRV     10 10 5061  srv-lab-t-668.zhaw.ch.

;; RECORDS: rr
_sip._tcp.mwi           SRV     10 10 5110  srv-lab-t-668.zhaw.ch.
_sip._tcp.vm            SRV     10 10 15060 srv-lab-t-668.zhaw.ch.
_sip._tcp.rr            SRV     10 10 5070  srv-lab-t-668.zhaw.ch.

;; RECORDS: im
;; RECORDS: a
 named-checkzone srv-lab-t-668.zhaw.ch srv-lab-t-668.zhaw.ch.zone
zone srv-lab-t-668.zhaw.ch/IN: loaded serial 2013081601
OK

ignoring out-of-zone data in my DNS file

Stepper motor / Schrittmotor

NEMA standard

Umrechnung

Convert oz-in to N-m
Convert Inch ounce-force, Torque
Conversion Calculator
umberfactory: Torque Conversions

In Großbritannien (UK) und in den Vereinigten Staaten von Amerika (US) ist das Avoirdupois-System (avdp-System) gebräuchlich:

1 Pound [lb]      = 16 Ounces [oz] = 256 Drams [dr] = 7000 Grains [gr]
1 Short Ton [tn]  = 2000 Pounds [lb]
1 Long Ton [l.tn] = 2240 Pounds [lb]
1,0 Pound [lb]    = 0,45359237 Kilogramm [kg]

NEMA Toleranzen:

NEMA17
42 mm        = 1.65354 inches
1.7 inches   = 43.18 mm

NEMA 23
57 mm        = 2.24409 inches
2.3 inches   = 58.42 mm

Stepper Motor

Wantai Motor
Longs Motor

Manufacturer Model NEMA Nr. Rate Current (A) Resistance (Ω/phase) Inductance (mH/phase) Holding Torque (g-cm) Holding Torque (kg-cm) Holding Torque (N-cm) Holding Torque (oz-in) Motor Length (mm)
Wantai Motor 42BYGHW208 17 0.4 A 30 Ω 37 mH 2800 2.8 27.458 38.884 34
Wantai Motor 42BYGHW804 17 1.2 A 3 Ω 5 mH 4500 4.5 44.129 62.493 48
Wantai Motor 42BYGHW811 17 2.5 A 1.5 Ω 1.8 mH 4800 4.8 47.072 66.659 48
Wantai Motor 57BYGH115-003 23 3 A 2.1 Ω 30’000 30 294.200 416.622 115
Wantai Motor 57STH115-4204A 23 4.2 A 0.9 Ω 30’000 30 294.200 416.622 115
Longs Motor 17HS0413 17 1.3 A 3.2 Ω 5.5 mH 5302.502 5.302 52 73.638 48
Longs Motor 17HS0417 17 1.7 A 1.8 Ω 3.2 mH 5302.502 5.302 52 73.638 48

eBay

Rattr Motor – infoshine15 (Email: sale2@rattmmotor.com, MSN: tonyswj@hotmail.com) [Longs Motor?]
Longs Motor – longsmotor99 (MSN: marychen1987@hotmail.com, Skype: marychen198711)

Military quality! Nema17 CNC Stepper motor 60mm/95 Oz-in/ 1.8A Military motor
German Ship&Free Ship: 10 pcs Nema 17 stepper motor 2.5A 48mm 48N.CM 3D pinter
10 pcs Nema 17 stepper motor with 68 oz.in, 4 leads 2.5A CNC
10pcs Nema 17 stepper motor 75 oz.in bipolar CNC PLASMA

Stepper Driver

  • TI DRV8824
  • TI DRV8825
  • Allegro A4982
  • Allegro A4983
  • Allegro A4988 (like A4983, overcurrent protection, internal 100k pull-down on MS1 microstep selection pin)
  • Toshiba TB6560AHQ

Spannung

Die Schrittmotor-FAQ

Frage

Warum soll ich die SM-Karte mit 24Volt oder mehr betreiben, wenn auf dem Motor 5,1 Volt steht? Wird der nicht überlastet?

Antwort

Zumindest bei den hier vorgestellten Schaltungen, aber auch bei den meisten anderen Schaltungen mit 1 Ampere oder mehr Wicklungsstrom, handelt es sich um stromgeregelte Schaltungen. Dabei sorgt der Stromregler dafür, das der Motor nur soviel Strom ‘bekommt’, wie eingestellt wurde (in der Regel also der Nennstrom des Motors). Dies wird durch häufiges Ein- und Ausschalten der Motorwicklung erreicht. Der Stromregler arbeitet also wie ein (Abwärts)-Schaltregler. Am Motor stellt sich (nach dem Ohm’schen Gesetz) quasi automatisch die Nennspannung des Motors ein.

Drehmomentkurve

Schrittmotor Schritte pro Sekunde
Super Grobi: Im Datenblatt des Schrittmotors siehst Du die Drehmomentkurve, also welche Kraft der Motor bei welcher Schrittrate leistet. Die Kurve endet irgendwo bei 4000 Schritten/Sekunde. Der Motor hat einen Schrittwinkel von 1,8° also 200 Schritte pro Umdrehung. Daher kannst Du Also maximal 4000/200 = 20 U/sek oder 1200 U/min erreichen. Die maximale Kraft hat der Motor im Bereich von
1000..1500 Schritten pro Sekunde.

Schrittverlust

Schrittmotor Schritte pro Sekunde
Super Grobi: Du must auf jeden Fall eine Anfahr- und eine Bremsrampe fahren die je nach Belstung flacher oder steiler seinen darf. Gibst Du sofort 1500 Schritte drauf, wird der Motor vermutlich nicht drehen. Er brummt dann nur und “verliert” die Schritte. Die Bremsrampe brauchst Du weil der Motor bei ruckartigem Ausschalten der Schritte weiterdrehen würde und Du dann die Schrittposition nicht mehr kennst. Die Bremsrampe kann i.d.R. steiler sein als die Beschleunigungsrampe.
Schrittverlust kann auch beim Fahren auftreten, wenn die Belastung im Grenzbereich ist. Das merkt man nicht unbedingt sofort. Erst wenn der Motor bei z.B. 1000 Schritten vorwärts und 1000 Schritten rückwärts nicht wieder am Ausgangspunkt landet, weist Du das etwas falsch läuft.
Ansonsten kannst Du natürlich auch eine einfache lineare Steigung programmieren.

Überhitzung

Schrittmotor Schritte pro Sekunde
Super Grobi: Beim Schrittverlust wird die zugeführte Energie in Wärme umgewandelt, nicht in Umdrehung. Solange der Motor dadurch nicht überhitzt, geht er auch nicht kaputt.

BIND: HOWTO Close an Open DNS

BIND 9.9.7
BIND 9.9.5

Book: ZyTrax Pro DNS and BIND

Time-to-Live (TTL) Values
Start of Authority Resource Record (SOA)
BIND Time formats
IPv6 Address Record (AAAA)
HOWTO Close an Open DNS
DNS BIND Query Statements
DNS Configuration Types
DNS Sample BIND Configurations
$ORIGIN, @ and blank Substitution
DNS BIND9 logging Clause

    #s = seconds = # x 1 seconds (really!)
    #m = minutes = # x 60 seconds
    #h = hours = # x 3600 seconds
    #d = day = # x 86400 seconds
    #w = week = # x 604800 seconds

Problems

nslookup not found in FreeBSD 10

# pkg install bind-tools

May you please add alias for nslookup?
FreeBSD 10 sysinstall, nslookup

named: the working directory is not writable

# chown -R bind:bind /var/named/etc/namedb

named: the working directory is not writable

open: /usr/local/etc/rndc.key: file not found

# rndc-confgen -a

Bind does not provide /etc/rndc.key

Stopping named: rndc failed, trying killall: .


Die Verwendung von rndc
Using rndc
Stopping named: rndc failed, trying killall: .

rndc: ‘stats’ failed: permission denied

options {
    dump-file       "/var/named/dump/named_dump.db";
    statistics-file "/var/named/stats/named.stats";
};

rndc works, but rndc stats doesnt
rndc dumpdb could not open dump file

Howto

DNS-Request

- autoritativ (der Server holt die Daten aus einer lokalen Zonendatei)
- nicht-autoritativ
  o rekursiv (der Server holt die Daten von einem anderen Nameserver)
  o iterativ (der Server antwortet mit einem oder mehreren Verweisen
              oder einem Resource Record auf andere Nameserver)

Rekursive und iterative Namensauflösung

recursion
If yes, and a DNS query requests recursion, then the server will attempt to do all the work required to answer the query. If recursion is off and the server does not already know the answer, it will return a referral response. The default is yes. Note that setting recursion no does not prevent clients from getting data from the server’s cache; it only prevents new data from being cached as an effect of client queries. Caching may still occur as an effect the server’s internal operation, such as NOTIFY address lookups. See also fetch-glue above.

fetch-glue
This option is obsolete. In BIND 8, fetch-glue yes caused the server to attempt to fetch glue resource records it didn’t have when constructing the additional data section of a response. This is now considered a bad idea and BIND 9 never does it.

BIND 9 Configuration Reference

Configuring an Authoritative-Only Name Server

Problem
You want to configure an “authoritative-only” or nonrecursive name server.
Cooking with DNS & BIND

Wireshark

(dns) && (dns.qry.type == 1)   => Record type A
$ tcpdump -s 1500 -p 53 -w output.pcap
-s <number>   number in bytes per packet
-w <file>     output file
-p <number>   port number (ex. 53 = DNS)

List of DNS record types

Fail2Ban

Fail2Ban
DNS Root Query Amplification with Fail2Ban
Fail2Ban with FreeBSD
Integrating PF with Fail2ban 0.9

Tutorials

A Nonrecursive Name Server, O’Reilly DNS and BIND
How to Disable External DNS recursion?
Configuring Bind Non Recursive
Wikipedia: Rekursive und iterative Namensauflösung
What is a “recursive DNS query”?

# /usr/sbin/named -t /var/named -u bind -fg
-t chroot() to directory after processing the command line arguments
-u setuid() to user after completing privileged operations
-f Run the server in the foreground
-g Run the server in the foreground and force all logging to stderr
recursion  no;

# /usr/sbin/named -t /var/named -u bind -fg
05-Aug-2013 19:58:10.872 starting
05-Aug-2013 19:58:10.876 listening on IPv4 interface em0, 1.2.3.4#53
05-Aug-2013 19:58:10.877 listening on IPv4 interface lo0, 127.0.0.1#53
05-Aug-2013 19:58:10.880 running
05-Aug-2013 19:59:11.360 unexpected RCODE (REFUSED) resolving 'www.XXX.ch/A/IN': 1.2.3.4#53
05-Aug-2013 19:59:13.359 lame server resolving 'blog.XXX.net' (in 'XXX.net'?): 1.118.193.3#53
05-Aug-2013 19:59:13.359 lame server resolving 'blog.XXX.net' (in 'XXX.net'?): 2.134.128.59#53
05-Aug-2013 19:59:13.360 lame server resolving 'blog.XXX.net' (in 'XXX.net'?): 2.134.128.59#53
05-Aug-2013 19:59:13.361 lame server resolving 'blog.XXX.net' (in 'XXX.net'?): 1.118.193.3#53

05-Aug-2013 20:00:22.718 shutting down
05-Aug-2013 20:00:22.719 no longer listening on 1.2.3.4#53
05-Aug-2013 20:00:22.719 no longer listening on 127.0.0.1#53
05-Aug-2013 20:00:22.720 exiting
# /usr/local/sbin/named -t /var/named -u bind -fg -c /etc/namedb/named.conf
29-Sep-2015 20:16:29.117 starting BIND x.x.x. -t /var/named -u bind -fg -c /etc/namedb/named.conf
29-Sep-2015 20:16:29.117 found 2 CPUs, using 2 worker threads
29-Sep-2015 20:16:29.117 using 2 UDP listeners per interface
29-Sep-2015 20:16:29.120 using up to 4096 sockets
29-Sep-2015 20:16:29.137 ENGINE_by_id failed (crypto failure)
29-Sep-2015 20:16:29.138 error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
29-Sep-2015 20:16:29.138 error:260B6084:engine routines:DYNAMIC_LOAD:dso not found:eng_dyn.c:450:
29-Sep-2015 20:16:29.138 error:2606A074:engine routines:ENGINE_by_id:no such engine:eng_list.c:417:id=gost
29-Sep-2015 20:16:29.140 initializing DST: crypto failure
29-Sep-2015 20:16:29.140 exiting (due to fatal error)

# /usr/local/sbin/named -u bind -fg -c /etc/namedb/named.conf
29-Sep-2015 20:16:51.826 starting BIND x.x.x -u bind -fg -c /etc/namedb/named.conf
29-Sep-2015 20:16:51.826 found 2 CPUs, using 2 worker threads
29-Sep-2015 20:16:51.826 using 2 UDP listeners per interface
29-Sep-2015 20:16:51.829 using up to 4096 sockets
29-Sep-2015 20:16:51.853 loading configuration from '/etc/namedb/named.conf'
29-Sep-2015 20:16:51.855 using default UDP/IPv4 port range: [49152, 65535]
29-Sep-2015 20:16:51.855 using default UDP/IPv6 port range: [49152, 65535]
29-Sep-2015 20:16:51.856 listening on IPv4 interface em0, 195.134.157.20#53
29-Sep-2015 20:16:51.858 listening on IPv4 interface lo0, 127.0.0.1#53
[...]
29-Sep-2015 20:16:51.891 command channel listening on 127.0.0.1#953
29-Sep-2015 20:16:51.891 not using config file logging statement for logging due to -g option
29-Sep-2015 20:16:51.892 managed-keys-zone: loaded serial 0
29-Sep-2015 20:16:51.893 redirect-zone: loaded serial 2014060401
29-Sep-2015 20:16:51.907 zone 157.x.x.in-addr.arpa/IN: loaded serial 2007020101
29-Sep-2015 20:16:51.912 zone xxx.ch/IN: loaded serial 2007020101
29-Sep-2015 20:16:51.929 zone yyy.ch/IN: loaded serial 2007020101
29-Sep-2015 20:16:51.930 all zones loaded
29-Sep-2015 20:16:51.933 running

What is the meaning of these BIND log messages?

  • “unexpected RCODE (SERVFAIL)…”
  • “lame server resolving…”
allow-recursion { 127.0.0.1; };

05-Aug-2013 20:05:39.820 starting
05-Aug-2013 20:05:39.824 loading configuration from '/etc/namedb/named.conf'
05-Aug-2013 20:05:39.825 listening on IPv4 interface em0, 1.2.3.4#53
05-Aug-2013 20:05:39.825 listening on IPv4 interface lo0, 127.0.0.1#53
05-Aug-2013 20:05:39.830 zone 0.0.127.in-addr.arpa/IN: loaded serial 2007020101
05-Aug-2013 20:05:39.832 zone AAA.ch/IN: loaded serial 2007020101
05-Aug-2013 20:05:39.833 zone BBB.ch/IN: loaded serial 2007020101
05-Aug-2013 20:05:39.833 zone CCC.ch/IN: loaded serial 2007020101
05-Aug-2013 20:05:39.834 zone DDD.ch/IN: loaded serial 2007020101
05-Aug-2013 20:05:39.835 zone localhost/IN: loaded serial 2007020101
05-Aug-2013 20:05:39.837 running
05-Aug-2013 20:05:39.837 zone localhost/IN: sending notifies (serial 2007020101)
05-Aug-2013 20:05:39.838 zone AAA.ch/IN: sending notifies (serial 2007020101)
05-Aug-2013 20:05:39.838 zone BBB.net/IN: sending notifies (serial 2007020101)
05-Aug-2013 20:05:39.838 zone CCC.net/IN: sending notifies (serial 2007020101)
05-Aug-2013 20:05:39.838 zone DDD.net/IN: sending notifies (serial 2007020101)
05-Aug-2013 20:05:39.838 zone 0.0.127.in-addr.arpa/IN: sending notifies (serial 2007020101)
05-Aug-2013 20:05:39.838 client 1.2.3.4#56328: received notify for zone 'localhost'
05-Aug-2013 20:05:40.339 client 1.2.3.4#56328: received notify for zone 'AAA.ch'
05-Aug-2013 20:05:40.339 client 1.2.3.4#56328: received notify for zone 'BBB.net'
05-Aug-2013 20:05:40.340 client 1.2.3.4#56328: received notify for zone 'CCC.net'
05-Aug-2013 20:05:40.340 client 1.2.3.4#56328: received notify for zone 'DDD.net'
05-Aug-2013 20:05:40.840 client 1.2.3.4#56328: received notify for zone '0.0.127.in-addr.arpa'

05-Aug-2013 20:09:10.348 shutting down
05-Aug-2013 20:09:10.348 no longer listening on 1.2.3.4#53
05-Aug-2013 20:09:10.348 no longer listening on 127.0.0.1#53
05-Aug-2013 20:09:10.350 exiting

How to setup Local Authoritative DNS
BIND 10: Authoritative DNS Server