Blog J.Schweiss

Infosammlung zu .NET- Programmier-Themen & Elektronik

VirtualHere

clock April 14, 2017 23:01 by author Administrator

Raspberry PI als USB-Server

here



better arduino debugging

clock Februar 9, 2016 15:16 by author Administrator

using printf with this ref

 

Where the specifier character at the end is the most significant component, since it defines the type and the interpretation of its corresponding argument:

specifier Output Example
d or i Signed decimal integer 392
u Unsigned decimal integer 7235
o Unsigned octal 610
x Unsigned hexadecimal integer 7fa
X Unsigned hexadecimal integer (uppercase) 7FA
f Decimal floating point, lowercase 392.65
F Decimal floating point, uppercase 392.65
e Scientific notation (mantissa/exponent), lowercase 3.9265e+2
E Scientific notation (mantissa/exponent), uppercase 3.9265E+2
g Use the shortest representation: %e or %f 392.65
G Use the shortest representation: %E or %F 392.65
a Hexadecimal floating point, lowercase -0xc.90fep-2
A Hexadecimal floating point, uppercase -0XC.90FEP-2
c Character a
s String of characters sample
p Pointer address b8000000
n Nothing printed.
The corresponding argument must be a pointer to a signed int.
The number of characters written so far is stored in the pointed location.
 
% A % followed by another % character will write a single % to the stream. %



ACS712–Oversampling

clock November 22, 2015 20:39 by author Administrator

Strommessung

Grundlagen



CC1101 + Panstamp-Arduino-Library und die Probleme der besonderen Art …

clock November 9, 2015 05:53 by author Administrator

Zum Test der Funkübertragung  zwischen zwei CC1101-Modulen im 868 MHz-Bereich war ich fast am Verzweifeln angelangt.

Ich hatte 3 verschiedene Module erstanden:

1. 433 MHz-Typ mit 2*5p Stiftleiste.

2. 868 MHz Modul von Pollin

3. 868 MHz Modul von AliExpress 

Wie bei so vielen Forumsbeiträgen hatte ich folgendes Phänomen (Nano,328):

Die einfachen Beispiele der PanStamp-Library sind einfach nicht  zum Laufen zu bringen…

Grund:

Wenn man davon ausgeht, dass die Module mit gleichem Chip (TI CC1101) und gleicher 868 MHz Ausrichtung,

bei gleicher Register-Einstellung für Sender und Receiver  funktionieren sollten, hat man sich getäuscht!

Mit Hilfe von SDRSharp, dem SmartRFStudio und Vergleich von allen Modulen als SENDER (!)  war in SDRSharp eindeutig zu erkennen,

dass die verschiedenen Module auf unterschiedlicher Frequenz sendeten, also deutlich außerhalb der Erkennungs-Bandbreite.

Wohlgemerkt, bei gleicher Standard-Register-Parametern!

Abhilfe:

ein Modul mit passender Frequenz belassen, das andere Modul mit Hilfe der SmartRF-Studio-Einstellungen die Trägerfrequenz zu der des ersten Moduls verschieben.

Das lässt sich in SDRSharp (HowTo) nachvollziehen, ohne keine Chance die Ursache zu entdecken.

Und pronto: Die Ausgabe im Arduino-Serial-Monitor mit angepassten Frequenz-Parametern erfolgte im Receiver-Modus prompt:

 

 image

Diese Werte in CC1101.h sind anzupassen, hier als Beispiel meine Werte:

//--- Carrier frequency = 868 MHz
#define CC1101_DEFVAL_FREQ2_868  0x21        // org. 21 Frequency Control Word, High Byte
#define CC1101_DEFVAL_FREQ1_868  0x64        // org. 62 Frequency Control Word, Middle Byte
#define CC1101_DEFVAL_FREQ0_868  0x62        // org. 76 Frequency Control Word, Low Byte

Man legt sich also 2 verschiedene Versionen davon an. Eine für den Sender, die andere für den Receiver. Winking smile

Was ich noch nicht sagen kann, ob die Frequenz bei zwei identischen Modulen gleich ist ?


Panstamp-Sender-Code:

/* ======================================================
    Antenna lengths:
   
    If you decide to use your panStamps with a wire stub as an antenna,
   
you will have to use one of the following lengths, depending on your carrier frequency: 
   
Frequency = 868 MHz:
   
      Quarter Wavelength: 82.2 mm = 3.235 inch
      Half Wavelength:   164.3 mm = 6.470 inch
   
    Frequency = 915 MHz:
   
      Quarter Wavelength: 77.9 mm = 3.069 inch
      Half Wavelength:   155.9 mm = 6.138 inch
   
    Frequency = 433 MHz:
   
      Quarter Wavelength: 164.7 mm =  6.484 inch
      Half Wavelength:    329.4 mm = 12.968 inch 
===========================================================
*/

/** ----------------------------------------------------
  ** SPI pins
  ** definiert in C:\Users\<username>\Documents\Arduino\libraries\Panstamp2\spi.h 


  #define SPI_SS          10     // PB2 = SPI_SS = CSN
  #define SPI_MOSI        11     // PB3 = MOSI
  #define SPI_MISO        12     // PB4 = MISO
  #define SPI_SCK         13     // PB5 = SCLK
  #define GDO0             2     // PD2 = INT0

 
  #define PORT_SPI_MISO   PINB
  #define PORT_SPI_SS     PORTB
  #define PORT_GDO0       PIND
 
  #define BIT_SPI_MISO    4
  #define BIT_SPI_SS      2
  #define BIT_GDO0        2 
  
 
----------------------------------------------------*/

#include <calibration.h>
#include <cc1101.h>
#include <ccpacket.h>
#include <commonregs.h>
#include <config.h>
#include <nvolat.h>
#include <panstamp.h>
#include <register.h>
#include <repeater.h>
#include <spi.h>
#include <swcommand.h>
#include <swpacket.h>
#include <swquery.h>
#include <swstatus.h>

#include <EEPROM.h>

CC1101 cc1101;

// The LED is wired to the Arduino Output 4 (physical panStamp pin 19)
// im NANO mit 868 Modul (CUL)ist die externe LED an D9 angeschlossen!
#define LEDOUTPUT 9

// counter to get increment in each loop
byte counter;
byte b;
byte syncWord = 199;

void blinker()
{
digitalWrite(LEDOUTPUT, HIGH);
delay(50);
digitalWrite(LEDOUTPUT, LOW);
delay(50);
}

void setup()
{
Serial.begin(38400);
Serial.println("Starting CC1101_js_send...");

// setup the blinker output
pinMode(LEDOUTPUT, OUTPUT);
digitalWrite(LEDOUTPUT, LOW);

// blink once to signal the setup
blinker();

// reset the counter
counter=0;
Serial.println("initializing...");
 
//--- initialize the RF Chip
cc1101.init();

cc1101.setSyncWord(&syncWord, false); 
    
cc1101.setCarrierFreq(CFREQ_868);
 
cc1101.disableAddressCheck();
 
//cc1101.setTxPowerAmp(PA_LowPower);

delay(1000);

Serial.print("CC1101_PARTNUM "); //cc1101=0
Serial.println(cc1101.readReg(CC1101_PARTNUM, CC1101_STATUS_REGISTER));
Serial.print("CC1101_VERSION "); //cc1101=4
Serial.println(cc1101.readReg(CC1101_VERSION, CC1101_STATUS_REGISTER));
Serial.print("CC1101_MARCSTATE ");
Serial.println(cc1101.readReg(CC1101_MARCSTATE, CC1101_STATUS_REGISTER) & 0x1f);
Serial.println("device initialized to 868.175 MHZ. Setup done.");
}

void send_data()
{
CCPACKET data;
data.length = 10;
byte blinkCount = counter++;

data.data[0] = 5;
data.data[1] = blinkCount;
data.data[2] = 0;
data.data[3] = 1;
data.data[4] = 0;
//cc1101.flushTxFifo();

Serial.print("CC1101_MARCSTATE ");
Serial.println(cc1101.readReg(CC1101_MARCSTATE, CC1101_STATUS_REGISTER) & 0x1f);
if(cc1101.sendData(data))
  {
   Serial.print(blinkCount, HEX);
   Serial.println(" sent ok :)");
   blinker();
}
else
{
   Serial.println("sent failed :(");
   blinker();
   blinker();
}
}

void loop()
{
    send_data();
    delay(1000);
}




Pi Clock DS1307

clock November 8, 2015 17:18 by author Administrator

Article

LevelShifter

SPI at RPI and how to install



ESP8266 and FHEM

clock Oktober 18, 2015 21:47 by author Administrator

here

Basic

ESP User Manual

NetIo

Hardware

 

Zu GPIO:

Zu Device-Tree:



ESP8266

clock Oktober 6, 2015 05:25 by author Administrator

Kochbuch

Schaltplan

Kurzinfos

Intro

Projects



SDR + NRF24L01

clock September 19, 2015 20:19 by author Administrator

here

usage and antenna designer (BiQuad)

433 MHz  Antenna Receiver Transceiver Module & Mini Version

Sketches Range Tutorial Hacking

 NRF24L01 with RASPI and node.js Beginner

Servos



RASPI & WLAN

clock September 5, 2015 20:44 by author Administrator

here

 

SPI on RASPI and here in practice

SPI-basics on wikipedia



1,8 “ TFT on Raspi

clock Mai 12, 2015 05:54 by author Administrator

with ST7735

Temperature-measurements with DS18S20



SSH-Keys

clock Mai 9, 2015 04:08 by author Administrator

SSH extern

Brute force bruteSSH

Tastaturlayout ändern

WLAN-Adapter

Samba



SDR mit Pi

clock April 25, 2015 03:21 by author Administrator

HowTo



F() Macro

clock April 12, 2015 23:48 by author Administrator

explained on programming

Serial.println(F(“Hello World”));
Lcd.print(F(“W”));

The F() macro tells the compiler to leave this particular array in PROGMEM. Then when it is time to access it, one byte of the data is copied to RAM at a time. There’s a small performance overhead for this extra work. However, printing strings over Serial or to a LCD is a really slow process, so a few extra clock cycles really won’t matter.

ProgMem

 

Serial: Multi Digit Integers

void

setup()

{

Serial.begin(9600);

}

void

loop() {

char buffer[] = {' ',' ',' ',' ',' ',' ',' '}; // Receive up to 7 bytes

while (!Serial.available()); // Wait for characters

Serial.readBytesUntil('n', buffer, 7);

int incomingValue = atoi(buffer);

Serial.println(incomingValue);

}

void

setup()

{

Serial.begin(9600);

}

unsigned

int integerValue=0; // Max value is 65535

char

incomingByte;

void

loop()

{

if (Serial.available() > 0) { // something came across serial

integerValue = 0; // throw away previous integerValue

while(1) { // force into a loop until 'n' is received

incomingByte = Serial.read();

if (incomingByte == '\n') break; // exit the while(1), we're done receiving

if (incomingByte == -1) continue; // if no characters are in the buffer read() returns -1

integerValue *= 10; // shift left 1 decimal place

// convert ASCII to integer, add, and shift left 1 decimal place

integerValue = ((incomingByte - 48) + integerValue);

}

Serial.println(integerValue); // Do something with the value

}

}



Function Pointer in C++

clock April 12, 2015 21:56 by author Administrator

Article



USB serial device by VID/PID

clock April 12, 2015 21:43 by author Administrator

here

 

Imports System
Imports System.IO
Imports System.Management
Imports Microsoft.Win32
Imports System.Text.RegularExpressions
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rk1 As RegistryKey = Registry.LocalMachine  ' HKEY_LOCAL_MACHINE
        Dim rk2 As RegistryKey = rk1.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum")  ' HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
        TextBox_FileDump.AppendText(vbCrLf + "rk1 = " + rk1.ToString())
        TextBox_FileDump.AppendText(vbCrLf + "rk2 = " + rk2.ToString())
 
        Dim VID As String = "0403"
        Dim PID As String = "6001"
        Dim pattern As String = String.Format("^VID_{0}.PID_{1}", VID, PID)
        Dim _rx As Regex = New Regex(pattern, RegexOptions.IgnoreCase)
        Dim s3 As String
        For Each s3 In rk2.GetSubKeyNames()
            TextBox_FileDump.AppendText(vbCrLf + "s3 = " + s3)
 
            Dim rk3 As RegistryKey = rk2.OpenSubKey(s3)
            TextBox_FileDump.AppendText(vbCrLf + "rk3 = " + rk3.ToString())
 
            Dim s As String
            For Each s In rk3.GetSubKeyNames()
                TextBox_FileDump.AppendText(vbCrLf + "s = " + s)
 
                If _rx.Match(s).Success Then
                    Dim rk4 As RegistryKey = rk3.OpenSubKey(s)
                    TextBox_FileDump.AppendText(vbCrLf + "rk4 = " + rk4.ToString())
 
                    Dim s2 As String
                    For Each s2 In rk4.GetSubKeyNames()
                        TextBox_FileDump.AppendText(vbCrLf + "s2 = " + s2)
 
                        Dim rk5 As RegistryKey = rk4.OpenSubKey(s2)
                        Dim rk6 As RegistryKey = rk5.OpenSubKey("Device Parameters")
                        TextBox_FileDump.AppendText(vbCrLf + "rk5 = " + rk5.ToString())
                        TextBox_FileDump.AppendText(vbCrLf + "rk6 = " + rk6.ToString())
 
                        TextBox_FileDump.AppendText(vbCrLf + "PORT NAME = " + rk6.GetValue("PortName"))
 
                    Next
 
                End If
 
            Next
 
        Next
 

    End Sub



LIRC on Raspi

clock April 12, 2015 20:55 by author Administrator

Article



PI

clock März 26, 2015 23:51 by author Administrator

Anmeldung per SSH-Key
USB Stick einbinden
Apache-Logs abschalten
Apache, MySQL und PHP auf Raspberry Pi
Gehäuse für Raspberry Pi
Samba auf Raspberry Pi
Einen neuen Benutzer anlegen
Raspberry Pi Erstinstallation
Raspberry Pi Modell B Rev. 2.0
GPIO Bash
Wiring Pinout PI



LevelShifter 3V3 to 5V

clock März 26, 2015 23:23 by author Administrator

Here



Raspi Interface Circuits

clock März 26, 2015 18:48 by author Administrator

here and levels

allaboutcircuits overview

Raspi 433Utils



RFID

clock März 17, 2015 06:05 by author Administrator

Bauplan

AVR-NET-IO



Über den Author

Windows, Server, Programming, .Net, Tools, Arduino, RaspberryPi, IoT  & more

Sign in