Just found out that setting a flag in the timer and based on the flag, using uSerialN.flush() my problem., but I am still confused about the role of myusb.Task() function.
While testing another script, I accidentally commented out myusb.Task() in loop() and instead added delayMicroseconds(40). Surprisingly, the Master could read data from the Slave at up to 2.5 kHz.
This makes me wonder:
How to use properly use...
I've been working with the USBHost_t36 library on a Teensy and have written two sketches to test high-frequency USB serial communication.
The Master sends timestamped data packets to three USBSerial_BigBuffer ports at a fixed interval.
The Slave...
Detecting whether a device is connected to the port will not be sufficient to know if an application is ready to communicate. The earlier code you've used, to detect a change in DTR, is the most straightforward way.
What do you mean when you say that you are monitoring that bit "with a hardware serial port"? It's always good to show your code rather than having to guess what you're doing.
I have a working solution, but I'm unsure about the potential implications of these modifications.If anyone with more experience could take a look, I’d really appreciate it.
I modified the Teensy 4.1 core files to call a callback function...
Hey everyone,
I have a Teensy 4.1 controlling two motors, and I need a way to disarm them if the USB serial connection is lost. Right now, in my control loop, which runs every 1ms, I check Serial.dtr() before sending any commands to the motors...
not too long ago, I used the following script to time the canbus transmission, you may find it useful, by printing the message in the msg.buf field
For my test, I connected one of the can module to CAN1, and the other to CAN2. If you see that...
At this point I am quite content on how the USB Serial Transfers data, I had a new question, is there any way to trigger an interrupt based on USBSerial connection state? currently my code polls Serial.dtr(), was wondering if there is a cleaner...
with 2-3 devices the number of messages/sec the Host can receive should be <edit> tested/observed as it is using scheduled packets on a shared connection to and from host.
So, the other day I was annoyed doing some debugging and started looking at data acquisition devices and other ways of adding GPIO to a PC. The ones that did what I wanted were crazy expensive, 50k+ USD for a complete expandable setup with 40+...
I have ran the examples, will share a verison of the serial router soon, differnce will be, instead of hadware serial, will use the USBHost_t36 to route packets, Ethernet was another attractive options, for my use case at least, but I bought 12...
For USB Serial, I was transferring large chunks, later I found, If your buffer is entirely full, send_now works pretty well, it depends , how you stage the transfer.
I loved SerialTransfer, but one limitation for me was the max buffer size, I...
Agreed, already ordered the RAM chips.
By design, the system runs at constant rate. and the impacts are continuous as well, they contain high frequency content, but repeat at 3 Hz.
For the reason mentioned, CAN is not an option in my opinion as...
Hi @AndyA, thanks for taking the time to read my question.
The need for 1 kHz control is actually beyond my control. If it were up to me, I would have stuck with something like 50 Hz. The reason for 1 kHz control is that the trajectory my robot...
I just realized can't use Ethernet, because teensy 4.1 I have doesn't have chip soldered (NE version I believe).
Can I use my master teensy as USB host as a drop in replacement in that case?
just to give a picture, this is what my working master...
Heads up regarding SerialTransfer. The library as-is has max payload of 254 bytes per message, so it would work for the short messages you described, but not for very large ones.
I am using very short wires(<15 cm), with a teensy breakout boards and screw connectors for holding wires in place, intend to use rs 422 in the future, once everything is final.
Considering SerialTransfer , I might mod it a little to use crc32...
|
Fair point, A bit of background for anyone coming across this post:
I have a robot with six motor controllers, and the entire control system is developed and tuned to operate at a sampling frequency of 1 kHz.
Due to the setup, I am using one...
EDIT : There was a bug in my previous code, I found just after posting. Editing the question since I have a new question.
Hey everyone,
I'm working on a project involving two Teensy 4.1 boards, where I need to send structured binary data to the...
Without DMA, It wroked upto 700x6 shaped float array, for me that's 0.7 seconds of axis control data.
I will try soon with different vars.
I will also take a closer look at how crc/mpeg2 works, maybe that will give me some insight, so far I...
thanks @joepasquariello , for me it worked for 5x5 float arrays, didn't work for anything larger for some reason, the codes are shared below if anyone is interested.
Python code for checking ground truth -
import numpy as np
import crcmod
#...
Is there any library, with hardware acceleration? for teensy 4.1
I have been using FastCRC , from the src code I think it has hw acceleration for teensy 3.0 / 3.1 / 3.2 / 3.5 / 3.6.
Is there something similar for teensy 4.1?
I was hoping to get...
I looked into the folder where all the platformio libraries are located for teensy boards, and replaced it with the one from github, things are working now, thanks for the insight @shawn. Now this is working for all my projects.
I think you are right, If I paste the FASTCRC library, downloading directly from github, to the lib folder in the platformio project, it works fine and the function parameters seems to match -
@jmarsh and @joepasquariello , the root of all my problem is in the pio platform size_t is a uint16_t type var, any idea how can i change that. In arduino ide it gets interpreted as a uinjt32_t
I tried with a smaller array, array size of 2730...
I am using a teensy 4.1
I am trying to calculate CRC32 of a large float array, when I upload the code using arduino IDE, the result matches with the CRC32 calculated in python
how ever, when I upload the same code using platformio, the CRC is...
I’m using a Teensy 4.1 and need to transfer large amounts of data in a duplex manner. I have a few questions:
1. Performance of Serial.send_now()
I noticed that using Serial.send_now() reduces my data transfer speed. Specifically:
Without...
@MarkT , could you please specify which event handling are you talking about? inside the source code for delay.c i found delay calls yield at 1 KHz,
which in turn calls the serialEvent. So even If put delay(infinity), serialEvent is called at 1...
I’m implementing a real-time control system on a Teensy 4.1 and wanted to keep the loop() function completely empty, handling all computation inside interrupts. To achieve this, I tried the following approach:
const uint32_t maxUnsignedLong =...
thanks everyone, I measured the times with a scope and you @CollinK and @AndyA you were right, considering bit stuffing the timing is actually spot on, I tried with a multiple baudrates.
Thanks to @AndyA for showing me how to use the...
Hope everyone is doing well.
I come from a non programming background and never was formally taught any programming.
Now I am working on a project with a teensy 4.1, where I am trying to most of my work event based.
I'm running a system at...
I just noticed about the bus field in CAN_message_t struct
typedef struct CAN_message_t {
uint32_t id = 0; // can identifier
uint16_t timestamp = 0; // FlexCAN time when message arrived
uint8_t idhit = 0; // filter that id came...
@AndyA,
Many thanks for answering my question. Really appreciate it.
Follow up question,
If you are using two can transceivers, what happens then?
from the docs i see that -
"
In the background, the library has 3 weak functions used for...
The standard CAN "interrupt" logic follows the Arduino model, it's called as user level code when you call the .events() method. This is good in that it means it's harder to create code that locks up and avoids the gotchas that come with true...
Hi everyone,
First time posting here. I apologize in advance if I have broken any rules unknowingly.
I’m using a Teensy 4.1 with two CAN transceivers for a project.
CAN0 TX is connected to pin 22, RX to pin 23,
while CAN1 TX is on pin 1 and RX...