ISP vs SPI: interpreting signal labels - stm32

I'm interested in interfacing an STM32-based flight controller with external sensors based on the SPI (Serial Peripheral Interface) protocol. I have a couple of FCs (Flip32 F3, shown in attached photo; EMAX Skyline 32) that have a section of pins marked 5V/GND/RST/SCK/MISO/MOSI, which I presume are there to support ISP (In-System Programming); i.e., these pins allow the FC to act as a slave device for a programmer device that acts as the master. Other boards, such as the multiFlite NANO-B-FC, provide pin headders explicitly for SPI (other attached image), with CS (Chip Select) instead of RST.
Am I correct in these assumptions: i.e., the first kind of pinout (RST/SCK/MISO/MOSI) does not support an external SPI sensor, and the latter (CS/SCK/MISO/MOSI) does?
Flip32 F3 flight controller; ISP pads upper-left:
MultiFlight Nano-B flight controller pin header schematic:

I don't know these boards, just had a look at some pics on the internet.
The Flip32 F3 seems to have an Atmel ATMEGA microcontroller on board. (as an auxiliary MCU) I would assume that the 6 pins you found are the ISP interace for that MCU.
Just use a multimeter in continuity test mode and check if the 6 pads are connected to the ISP pins of the ATMEGA.
The board's main MCU STM32 is more likely programmed through the SWD (serial wire debug) interface. That's a pin-reduced JTAG alternative. Just google for it.
Here are some details if you are interested in Atmels ISP:
http://www.atmel.com/images/doc0943.pdf
If the firmware supports it (or you write one that supports it) you should be able to use the ISP interface as a normal SPI interface which it basically is.
ISP is usually done through a simple serial interface like JTAG, SWD or in the AVR case SPI.
Best way to find out: Read the datasheet of your ATMEGA.

Related

Connecting two PC's via RS485 (USB to RS485 converter)

I'm trying to establish Modbus RTU connection (for learning purposes) between two PC's (Win10). I'm using two USB to RS485 converters (D- connected together and D+ also connected together). This converters are connected to USB2.0 ports.
USB to RS485 converter
So I'm using "Modbus Poll" and "Modbus Slave" from "modbus tools".
First computer act as slave and has the following settings:
Slave configuration
Slave definition
Second computer act as master and has following settings:
Master configuration
Master definition
And my problem is, everytime i get "Timeout error":
Timeout error
So, what I'm doing wrong? I'm pretty sure converters are not damaged, because Win10 detecs them.
After all I just want to send simple value to another computer (via Modbus RTU) :)
Thanks
Well, this is not a real answer but I can provide some debugging suggestions.
In the past, I had problems with that RS-485 hardware you're using. It didn't work and I'm not sure why. The one I have uses a strange logic to drive DE pin of the MAX485. If I remember correctly, it inverts the TX line coming from CH340G using a NAND gate and feeds it to DE pin. I'm not sure if it was the problem, but I don't think it's a good design.
You may need pull-up and pull-down resistors on RS-485 lines to prevent it from floating when no driver is driving the bus. Some converters include them internally. Also, you may need 120 ohm termination resistors on both ends.
Instead of working with RS-485, you can simply use TTL logic for testing purposes. Use two USB-TTL converters, connect TX to RX (cross connection).
When debugging communication buses (USART, SPI, I2C etc.) always use logic analyzers. Even the cheapest one saves hours of debugging time.
you need to install proper drivers. I used following link which includes a how to video as well as download link for the drivers . Also disable RTS as its 2 wire RS485 so RTS cant be used.

Is there a CAN bus library for STM32 to direct connect with a CAN transceiver?

Many STM32 chipsets support 1 or 2 channel CAN PIN Outs.
Is there a CAN bus library for STM32 to direct connect with a CAN transceiver such as MCP2551? But it does not matter what the CAN transceiver is.
A CAN transceiver is just a high speed step down converter. (on a basic level)
CAN protocol works in a variant of voltage ranges. MCP2551 is a set CAN transceiver suitable for 12V and 24V systems. With added features to help with the physical layer like externally-controlled slope for reduced RFI emissions, detection of ground fault, voltage brown-out protection, etc.
It has no dependency on the CAN logic. It is just to help you with the bare physical layer.
To answer your question:
As RishabhHardas recommended, use the HAL library provided by STM32 through CubeMx.
Using CubeMx
This is a software provided by ST-Micro to help you setup the boilerplate code for any peripheral application.
You can also check out the examples projects provided by STM in the Cube. This will give you a kick-start in understanding CAN on STM32
STM32Cube_FW_F4_V1.9.0\Projects\STM324xG_EVAL\Examples\CAN\CAN_Networking
After setting it up, you'll be able to call HAL_CAN_Transmit() and HAL_CAN_Receive() by including the header.
Check out this discussion on STM32-Community.
For software, look for the CANtact open source project on Github. It is an implementation for the STM32F042. I had to adapt the project to build it under Atollic but it was not too hard and it works. It provides a SLCAN type of interface over a virtual COM port over USB, which is very fast and convenient.
There is also CAN code for the STM32F103 (Bluepill) (Google "lawicel-slcan") but that chip is not as convenient because you cannot use both CAN and USB at the same time (they share RAM buffers) so if you want CAN, you will not have USB, and routing the CAN messages over a UART will severely limit the bandwidth. That may be OK if your entire application runs on the STM32.

Reading KNX using Raspberry Pi 3 GPIO

My dad wants me to make kind of a smart home.
I would like to interface with KNX (a home automation protocol) using the GPIO on a Raspberry Pi 3. Ideally, I would like to build a web interface for it, but I don't have a clue how to interface with KNX in the first place.
Any suggestions?
It wont make sense for you to interpret and understand the KNX bus communication protocol directly. There is a massive specification behind the KNX bus which deals with so many problems from device addresses to collision detection. It would take years to master it and unless you develop KNX devices you really should not spend your time on it. You will be better off by doing the following:
Buy a KNX/IP gateway/interface such as https://www.mdt.de/en/products/product-detail/system-devices/system-devices/ip-interface.html
Understand that KNX bus traffic can be routed/tunneled to your home LAN/WIFI
Play around with one of the KNX libraries on GitHub. For example for C#: https://github.com/search?l=C%23&q=knx&type=Repositories&utf8=%E2%9C%93
If you want, have a look at my experimental .NET Core project which starts a radio streaming process when someone touches a button (in the bathroom in my case). It runs on any operation system (so Raspberry and Linux are fine) and you can find it here: https://github.com/ThomasZeman/KnxNetCore
check this website : http://michlstechblog.info/blog/raspberry-pi-eibknx-ip-gateway-and-router-with-knxd/ that might help. also there are special knx 2 ip devices sold by electronic stores
You can't connect the KNX bus to anything on the pi. The KNX bus has its own electrical specs, and you need specialized hardware to connect to it.
Such hardware is available, but probably a KNXnet/IP device (such as the Siemens N148) is a better option.
I see two options for you:
A) use an IP interface (e.g. the ones from MDT) and access the IP interface from your raspberryPi (e.g. with http://calimero-project.github.io/)
B) use a TPUART controller, which makes KNX TP telegrams accessible (r/w) to UART - see http://www.konnekting.de/konnekting-lernen/l1-knx-mit-arduino/

i2c address conflict between MPU6050 and DS3231

I am using MPU6050 onboard a GY-86 module. I also have a DS3231 RTC module. when i searched each data sheet i found that DS3231 and MPU6050 have same i2c address which is 0x68. I have read in the MPU data sheet that if i connect the AD0 pin to 3.3 the the address becomes 0x69. but i can't find any AD0 on my module . i only have vcc-3.3v-SCL-SDA-INTa-FSYNC-DROY
I think i have to change i2c address of mpu6050 or ds3231. so that they won't conflict . how can i change i2c dress of MPU or DS module.
Looking at the GY-86 schematic I found, the AD0 pin is hard grounded on the board. This means that unless you can find a trace on the board to cut (unlikely), there is no way to change the MPU6050 slave address. As far as I can see, the DS2321 cannot change its address either.
This leaves you with a few choices:
Change out on of the devices to a different model with a different address. I expect you really don't want to do this.
If your master device (which you did not specify) has multiple I2C bus controllers, hook each device to a different bus.
Use an I2C multiplexer to put the devices on different "virtual" busses. Here's a module with a 1-8 multiplexer which should do the job (though only a 1-2 is really necessary).

low level ethernet driver to read bits off phy layer

Is it possible to read the bits directly off the physical ethernet connection interface from a standard computer ethernet interface?
e.g., suppose I want to use the ethernet jack of a laptop as a differential logic probe(using a standard ethernet cable). Could I just potentially write a driver to get at the bits or is there a limit to how low a driver can go?
Essentially does the physical layer just send the bit stream to the device driver or does it do any decoding which will effect the interpretation of the bits or cause the device to malfunction(such using a different encoding scheme).
I guess what it boils down to, is, can we use the ethernet port as any standard digital differential communications link by writing a suitable driver or are we limited to the the ieee spec(8b/10b, etc...).
To answer shortly, probably not.
Here are some of the reason why:
On a hardware link layer, there is actually no electrical connection between the computer and the ethernet cable, it is electrically isolated by small transformer and is current and not voltage driven signal, so this will be the first problem to overcome, as you would have to send a fairly precise current over two lines rather than a voltage on a single line.
Ethernet transformers
PHY Hardware Interface: Then the next step, is that this is simply not controlled by the CPU where your code is being executed but by an ethernet PHY Chip interface, and there you have no (easy) way of flashing and controlling it. Some different PHY chip allows you different level of access, but I doubt you would find any that would allow you direct control over the transmission interface and even if it did, it would have to be implemented into the driver which is as well unlikely.
Ethernet PHY Controller
Perhaps some other solutions
as the comments above, if you want to have direct IO control on a computer, the best solution is over a serial or parallel port, perhaps you can find ethernet to serial or usb to serial port and then play with that but this would be digital signals.
Another thing you may want to use is the microphone input, as this accepts analog signals and you can have direct control over it, though be careful not burning your computer. (I've seen some bank card magnetic band using that on cellphones).
You can use libpcap/WinPcap to do this. Nevertheless you are not completely free in the choise of what you write/read on the wire. e.g. preamble and SFD must stil be there. This is so fundamental (because of noise resistance), that typical hardware just does not support anything different.
If you want to control completely everything, go to embedded hardware, find a board that uses a PHY that can give you that information and a processor that is capable of handling the data rates.