Troubles with Delphi TcomPort and RS485 - serial-port

I am trying to communicate with SMC LEC6 Servo motor controller via Delphi 7-TComPort Library. I have read related questions TComPort and Modbus. My question is if I want to send a massage containing 8 bytes, how can I specify the stop-bit/start-bit values ? and Do I need to send each byte as a packet and the stop-bit separately or it will be done automatically by the library ?

The start bit cannot be selected and this bit will be added to each byte automatically by your RS485 or RS232 hardware.
The stop bit type you may select in the component properties (e.g. 1 stop bit). This bit will be added automatically too.

Related

How do I use device registers to configure the operation of a device?

So I'm building a device to measure pressure in a clean room and using a Raspberry Pi Pico with a pressure sensor. I'm writing the code in Micropython and while the sensor is designed to be used right out of the box, I'm interested in how I use the device registers to modify it's operation (as well as other peripherals I have attatched). I understand the registers are 8-bit and how how the hex translates to binary and back. However, the code for the lists all the editable registers and their hex addresses but I have no idea how to modify the bits to turn off/on the features represented by each bit.
Does flipping each bit on/off just change the binary and thus changes the device register hex?
Thank you!

Arduino how to detect if a key is held down or not

I'm trying to detect whether a key is pressed down or not.
I have a digispark connected to a rotary encoder that together form a volume control wheel. The thing is I want to change what rotating the encoder does without hard coding it, so i made a program in c# that communicates with the Arduino with the unused keyboard keys f13-f14, but if I hardcode those keys instead of the volume keys.
When I plug in the device in a computer that does not have the program the Arduino is useless. So I needed to find a way to communicate with the Arduino and tell it the program is there. This was hard because the digispark has no serial support.
But what if I use those unused keys, let's say f15 as a Boolean. I need code for the digispark(which is basically an Arduino) to find out whether f15 is held down or not(true or false).

What is the difference between SPI and QPI (in embedded)?

In my project, I am using Winbond W25Q64 64-MB Serial flash, When i read datasheet of this serial flash there is two type:
SPI(W25Q64 FLASH ID :- 0xEF4017) and QPI(W25Q64FV FLASH ID :- 0xEF6017).
I know SPI very well, but first time i heard about QPI. So i have some Questions-
1.What is the difference's between SPI and QPI?
2.Can i use QPI communication type Flash(using SPI)?
3.What is the main feature's of QPI and what is QPI(a Communication Protocol or something else)?
Description of the QPI protocol is part of the datasheet (I have added the link into your question).
Judging from the description there, it does use four data lines for I/O (in contrast to SPI where one line is designated for input and another for output), thus saving clock cycles (compared to standard SPI) as one byte can be transfered in 2 cycles only. Available commands seems to be different too compared to SPI mode.
This chip supports some "extended" SPI modes (called Dual and Quad SPI) where more data lines are used for sending data to master. These are triggered by standard SPI command, but data transfer differs. See the details in the datasheet.
It is not compatible with "standard" SPI, and I am not sure if there is any common MCU supporting this mode. It looks similar to the SD card / SDIO, but I have no idea how much is it (dis)similar.
Yes, you can. The standard SPI (one input and one output data line) seems to be the default interface. The extended SPI modes are used in response to particular SPI commands only and the QPI mode has to be explicitly enabled by respective SPI command (see figure 3 in page 12).
In addition:
Quad SPI and QPI instructions require the non-volatile Quad
Enable bit(QE) in Status Register-2 to be set. When QE=1,
the /WP pin becomes IO2 and /HOLD pin becomes IO3.
...
QE bit is required to be set to a 1 before issuing an “Enable QPI
(38h)” to switch the device from Standard/Dual/Quad SPI to QPI,
otherwise the command will be ignored. When the device is in QPI mode,
QE bit will remain to be 1. A “Write Status Register” command in QPI
mode cannot change QE bit from a “1” to a “0”.
Advantage is faster data transfer at the same clock frequency. Details of the protocol are well described in the datasheet including timing plots etc.

Using BLE on Arduino to control multiple LEDs

I am trying to start a project in which I would create my own app on iOS using Swift to communicate with an Arduino 101 to control multiple LEDs. I have used this project as a base point.
After getting this to work with my custom app, I wanted to figure out how to make this work with multiple LEDs instead of just one. Currently, I am just performing writeCharacteristic to send a 1 or a 0 to the Arduino depending on which button I press (ON/OFF). However, for the new project, I need to be able to select one of the lights (select one of four output pins), and write a 1 or a 0 to turn it on and off. I didn't know what approach I should take to do this.
I don't need any code, just suggestions on how I can make this work through swift/Arduino code.
Thanks.
It's all explained in the manual.
https://www.arduino.cc/en/Reference/CurieBLE
Service design patterns
A characteristic value can be up to 20 bytes long. This is a key
constraint in designing services. Given this limit, you should
consider how best to store data about your sensors and actuators most
effectively for your application. The simplest design pattern is to
store one sensor or actuator value per characteristic, in ASCII
encoded values.
So either create a separate BLEBoolCharacteristic instance for each LED or combine the switch state of all leds in the same BLECharacteristic. For example you could encode 8 LED states in a single byte (1 LED per bit).
Do whatever you prefer. But read manuals...

Re-entrant code?

I am using the Wire library to move some data from a shield to the Arduino.
The shield always puts out exactly 36 bytes (GPS device), but the Arduino sees two data transfers that together add up to 36 bytes. Not always the same count in each of the transfers, but always 36 bytes total. The setup() routine is re-run every time the data comes in.
It's as if the library is re-entering the Arduino application and screwing it royally.
Is this possible?
If setUp() is being run every time data comes in (and are you sure about this?) then this means that the Arduino is resetting/restarting for some reason. How are you powering the GPS shield? If it is glitching the power to the Arduino (drawing too much current perhaps) then that could cause a reset. It could also be something with your code using up too much memory. I'd look at the power issue first.
If you are using Wire.available, note that it does not guarantee that it will return the number of bytes sent. You will need to call it repeatedly until it returns zero.
See an example in the Arduino documentation.

Resources